obf 0.7.9 → 0.8.0
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.
- checksums.yaml +4 -4
- data/lib/obf/pdf.rb +8 -4
- data/lib/obf/utils.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd00c599d531f48b18aebf3bb2bed662be381436
|
4
|
+
data.tar.gz: dbe1f4910cfdc5441f46137a348eec3fd5120254
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5cf06356cd608a7602ae2043cdd27d8eaa8f3d4f9323f90afc99e795f4c29ff89930c08a1b736accc4ff816384c758f26735040bdd074ad5eac48512a9de04c
|
7
|
+
data.tar.gz: a6257eb285b1bd76b93fcb2eedfac5a4201b191115996cd65ee2daf11df361bdb85ace887cabf5e24368331b09254a9b4cd3d51f1cbf7a425c3160347cd52cec
|
data/lib/obf/pdf.rb
CHANGED
@@ -47,11 +47,11 @@ module OBF::PDF
|
|
47
47
|
post = (idx + 1).to_f / obj['boards'].length.to_f
|
48
48
|
OBF::Utils.as_progress_percent(pre, post) do
|
49
49
|
pdf.start_new_page unless idx == 0
|
50
|
-
build_page(pdf, board, {'zipper' => zipper, 'pages' => obj['pages'], 'headerless' => !!opts['headerless'], 'text_on_top' => !!opts['text_on_top']})
|
50
|
+
build_page(pdf, board, {'zipper' => zipper, 'pages' => obj['pages'], 'headerless' => !!opts['headerless'], 'text_on_top' => !!opts['text_on_top'], 'transparent_background' => !!opts['transparent_background']})
|
51
51
|
end
|
52
52
|
end
|
53
53
|
else
|
54
|
-
build_page(pdf, obj, {'headerless' => !!opts['headerless'], 'text_on_top' => !!opts['text_on_top']})
|
54
|
+
build_page(pdf, obj, {'headerless' => !!opts['headerless'], 'text_on_top' => !!opts['text_on_top'], 'transparent_background' => !!opts['transparent_background']})
|
55
55
|
end
|
56
56
|
|
57
57
|
pdf.render_file(dest_path)
|
@@ -134,7 +134,11 @@ module OBF::PDF
|
|
134
134
|
pdf.bounding_box([5, vertical], :width => button_width - 10, :height => button_height - text_height - 5) do
|
135
135
|
image = (obj['images_hash'] || {})[button['image_id']]
|
136
136
|
if image
|
137
|
-
|
137
|
+
bg = 'white'
|
138
|
+
if options['transparent_background']
|
139
|
+
bg = "\##{fill}"
|
140
|
+
end
|
141
|
+
image_local_path = image && OBF::Utils.save_image(image, options['zipper'], bg)
|
138
142
|
if image_local_path && File.exist?(image_local_path)
|
139
143
|
pdf.image image_local_path, :fit => [button_width - 10, button_height - text_height - 5], :position => :center, :vposition => :center
|
140
144
|
File.unlink image_local_path
|
@@ -171,7 +175,7 @@ module OBF::PDF
|
|
171
175
|
end
|
172
176
|
pdf.fill_color "000000"
|
173
177
|
if options['pages']
|
174
|
-
pdf.
|
178
|
+
pdf.formatted_text_box [{:text => options['pages'][obj['id']], :anchor => "page1"}], :at => [doc_width - 100, text_height], :width => 100, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
|
175
179
|
end
|
176
180
|
end
|
177
181
|
end
|
data/lib/obf/utils.rb
CHANGED
@@ -115,7 +115,7 @@ module OBF::Utils
|
|
115
115
|
str
|
116
116
|
end
|
117
117
|
|
118
|
-
def self.save_image(image, zipper=nil)
|
118
|
+
def self.save_image(image, zipper=nil, background=nil)
|
119
119
|
if image['data']
|
120
120
|
if !image['content_type']
|
121
121
|
image['content_type'] = image['data'].split(/;/)[0].split(/:/)[1]
|
@@ -162,7 +162,8 @@ module OBF::Utils
|
|
162
162
|
# TODO: maybe convert to jpg instead of png?
|
163
163
|
# see https://github.com/prawnpdf/prawn/issues/324
|
164
164
|
# in that case, fill the image with a white background, perhaps?
|
165
|
-
|
165
|
+
background ||= 'white'
|
166
|
+
`convert #{file.path} -density 1200 -resize 200x200 -background "#{background}" -gravity center -extent 200x200 #{file.path}.jpg`
|
166
167
|
"#{file.path}.jpg"
|
167
168
|
end
|
168
169
|
end
|