pdf-wrapper 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/Rakefile +1 -1
- data/lib/pdf/wrapper/table.rb +17 -6
- metadata +2 -2
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/lib/pdf/wrapper/table.rb
CHANGED
@@ -84,15 +84,20 @@ module PDF
|
|
84
84
|
# TODO: when calculating the min cell width, we basically want the width of the widest character. At the
|
85
85
|
# moment I'm stripping all pango markup tags from the string, which means if any character is made
|
86
86
|
# intentioanlly large, we'll miss it and it might not fit into our table cell.
|
87
|
-
# TODO: allow column widths to be set manually
|
88
87
|
|
89
88
|
# calculate the min and max width of every cell in the table
|
90
89
|
t.cells.each_with_index do |row, row_idx|
|
91
90
|
row.each_with_index do |cell, col_idx|
|
92
91
|
opts = t.options_for(col_idx, row_idx).only(default_text_options.keys)
|
93
92
|
padding = opts[:padding] || 3
|
94
|
-
|
95
|
-
|
93
|
+
if opts[:markup] == :pango
|
94
|
+
str = cell.data.to_s.dup.gsub(/<.+?>/,"").gsub("&","&").gsub("<","<").gsub(">",">")
|
95
|
+
opts.delete(:markup)
|
96
|
+
else
|
97
|
+
str = cell.data.to_s.dup
|
98
|
+
end
|
99
|
+
cell.min_width = text_width(str.gsub(/\b|\B/,"\n"), opts) + (padding * 4)
|
100
|
+
cell.max_width = text_width(str, opts) + (padding * 4)
|
96
101
|
end
|
97
102
|
end
|
98
103
|
|
@@ -101,15 +106,21 @@ module PDF
|
|
101
106
|
t.headers.each_with_index do |cell, col_idx|
|
102
107
|
opts = t.options_for(col_idx, :headers).only(default_text_options.keys)
|
103
108
|
padding = opts[:padding] || 3
|
104
|
-
|
105
|
-
|
109
|
+
if opts[:markup] == :pango
|
110
|
+
str = cell.data.to_s.dup.gsub(/<.+?>/,"").gsub("&","&").gsub("<","<").gsub(">",">")
|
111
|
+
opts.delete(:markup)
|
112
|
+
else
|
113
|
+
str = cell.data.to_s.dup
|
114
|
+
end
|
115
|
+
cell.min_width = text_width(str.gsub(/\b|\B/,"\n"), opts) + (padding * 4)
|
116
|
+
cell.max_width = text_width(str, opts) + (padding * 4)
|
106
117
|
end
|
107
118
|
end
|
108
119
|
|
109
120
|
# let the table decide on the actual widths it will use for each col
|
110
121
|
t.calc_col_widths!
|
111
122
|
|
112
|
-
# now that we know how wide each column will be, we can calculate the
|
123
|
+
# now that we know how wide each column will be, we can calculate the
|
113
124
|
# height of every cell in the table
|
114
125
|
t.cells.each_with_index do |row, row_idx|
|
115
126
|
row.each_with_index do |cell, col_idx|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdf-wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Healy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-18 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|