class Origami::FDF
Class representing an AcroForm Forms Data Format file.
Constants
- Root
- Size
Attributes
header[RW]
revisions[RW]
Public Class Methods
read(path, options = {})
click to toggle source
# File lib/origami/extensions/fdf.rb, line 41 def self.read(path, options = {}) path = File.expand_path(path) if path.is_a?(::String) FDF::Parser.new(options).parse(path) end
Public Instance Methods
<<(object)
click to toggle source
# File lib/origami/extensions/fdf.rb, line 217 def <<(object) object.set_indirect(true) object.set_document(self) if object.no.zero? maxno = 1 maxno = maxno.succ while get_object(maxno) object.generation = 0 object.no = maxno end @revisions.first.body[object.reference] = object object.reference end
Also aliased as: insert
Catalog()
click to toggle source
# File lib/origami/extensions/fdf.rb, line 265 def Catalog get_object(@revisions.first.trailer.Root) end
indirect_objects()
click to toggle source
# File lib/origami/extensions/fdf.rb, line 248 def indirect_objects @revisions.inject([]) do |set, rev| set.concat(rev.objects) end end
Also aliased as: root_objects
save(path)
click to toggle source
# File lib/origami/extensions/fdf.rb, line 269 def save(path) bin = "".b bin << @header.to_s lastno, brange = 0, 0 xrefs = [ XRef.new(0, XRef::FIRSTFREE, XRef::FREE) ] xrefsection = XRef::Section.new @revisions.first.body.values.sort.each { |obj| if (obj.no - lastno).abs > 1 xrefsection << XRef::Subsection.new(brange, xrefs) brange = obj.no xrefs.clear end xrefs << XRef.new(bin.size, obj.generation, XRef::USED) lastno = obj.no obj.pre_build bin << obj.to_s obj.post_build } xrefsection << XRef::Subsection.new(brange, xrefs) @xreftable = xrefsection @trailer ||= Trailer.new @trailer.Size = @revisions.first.body.size + 1 @trailer.startxref = bin.size bin << @xreftable.to_s bin << @trailer.to_s if path.respond_to?(:write) io = path else path = File.expand_path(path) io = File.open(path, "wb", encoding: 'binary') close = true end begin io.write(bin) ensure io.close if close end self end
Private Instance Methods
init()
click to toggle source
# File lib/origami/extensions/fdf.rb, line 324 def init catalog = Catalog.new(:FDF => FDF::Dictionary.new) @revisions.first.trailer.Root = self.insert(catalog) end