Sha256: 675870b3dcbe08635a4fe9bc724030711b7cbbf6c8df89583a33c33da6b3679f
Contents?: true
Size: 1.23 KB
Versions: 34
Compression:
Stored size: 1.23 KB
Contents
module Medivo module FdfGenerator def self.file(info) PdfGenerator.tmp_pdf do |afile| afile.write "%FDF-1.2\x0d%\xe2\xe3\xcf\xd3\x0d\x0a"; # header afile.write "1 0 obj\x0d<< " # open the Root dictionary afile.write "\x0d/FDF << " # open the FDF dictionary afile.write "/Fields [ " # open the form Fields array info.each { |key, value| if value.class == Hash value.each { |sub_key, sub_value| afile.write '<< /T (' + key.to_s + '_' + sub_key.to_s + ') /V ' afile.write '(' + escape_data(sub_value) + ') /ClrF 2 /ClrFf 1 >> ' } else afile.write '<< /T (' + key.to_s + ') /V (' + escape_data(value) + ') /ClrF 2 /ClrFf 1 >> ' end } afile.write "] \x0d" # close the Fields array afile.write ">> \x0d" # close the FDF dictionary afile.write ">> \x0dendobj\x0d" # close the Root dictionary # trailer note the "1 0 R" reference to "1 0 obj" above afile.write "trailer\x0d<<\x0d/Root 1 0 R \x0d\x0d>>\x0d" afile.write "%%EOF\x0d\x0a" end end def self.escape_data(value) value.to_s.strip.gsub(/[\(]/, '\\(').gsub(/[\)]/, '\\)') end end end
Version data entries
34 entries across 34 versions & 1 rubygems