lib/fn/pdf/writer.rb in fn_document-0.9.4 vs lib/fn/pdf/writer.rb in fn_document-0.9.6

- old
+ new

@@ -25,12 +25,21 @@ options[:save_as] ||= (tmp = Tempfile.new("pdf"); tmp.close; tmp.path) write_xml translate(doc, options), options[:save_as] end def write_xml(xml, file) - xml.root.extend(FN::Node::Root) - xml.root.visit(FN::PDF::Struct.new) - return file + begin + xml.root.extend(FN::Node::Root) + xml.root.visit(FN::PDF::Struct.new) + return file + rescue Exception => e + $stderr.puts "="*88 + $stderr.puts "Tried to write_xml but failed. Logging XML and file:" + $stderr.puts "xml: #{xml}" + $stderr.puts "file: #{file}" + $stderr.puts "="*88 + raise e + end end def titlecase(str) face = str.split(SPACE).map{|s| s.capitalize }.join("") end \ No newline at end of file