217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
# File 'lib/prawn-fillform.rb', line 217
def fill_form_with(data={})
acroform_fields.each do |page, fields|
fields.each do |field|
number = page.to_s.split("_").last.to_i
go_to_page(number)
value = data[page][field.name].fetch(:value) rescue nil
if value.nil?
value = data[field.name].fetch(:value) rescue nil
end
options = field_hash.fetch(:options) rescue nil
options ||= {}
if value
value = value.to_s
x_offset = options[:x_offset] || self.class.fillform_x_offset
y_offset = options[:y_offset] || self.class.fillform_y_offset
if field.type == :text
fill_color options[:font_color] || field.font_color
text_box value, :at => [field.x + x_offset, field.y + y_offset],
:align => options[:align] || field.align,
:width => options[:width] || field.width,
:height => options[:height] || field.height,
:valign => options[:valign] || :center,
:size => options[:font_size] || ((size = field.font_size) > 0.0 ? size : font_size),
:style => options[:font_style] || field.font_style
elsif field.type == :button
bounding_box([field.x + x_offset, field.y + y_offset], :width => field.width, :height => field.height) do
if value =~ /http/
image open(value), :position => options[:position] || :center,
:vposition => options[:vposition] || :center,
:fit => options[:fit] || [field.width, field.height]
else
image value, :position => options[:position] || :center,
:vposition => options[:vposition] || :center,
:fit => options[:fit] || [field.width, field.height]
end
end
end
end
end
end
references = References.new(state)
references.delete!
end
|