lib/pdf/medivo/fdf_generator.rb in medivo-0.1.8 vs lib/pdf/medivo/fdf_generator.rb in medivo-0.1.9

- old
+ new

@@ -1,7 +1,8 @@ module Medivo module FdfGenerator + def self.file(info) afile = Tempfile.new('fdf', :encoding => 'ascii-8bit') 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 @@ -26,9 +27,37 @@ afile.write "trailer\x0d<<\x0d/Root 1 0 R \x0d\x0d>>\x0d" afile.write "%%EOF\x0d\x0a" afile.close afile end + + #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 \ No newline at end of file