Class: Origami::FDF
- Inherits:
-
Object
- Object
- Origami::FDF
- Defined in:
- lib/origami/extensions/fdf.rb,
lib/origami/parsers/fdf.rb
Overview
Class representing an AcroForm Forms Data Format file.
Defined Under Namespace
Classes: Header, Parser, Revision
Instance Attribute Summary collapse
-
#header ⇒ Object
Returns the value of attribute header.
-
#revisions ⇒ Object
Returns the value of attribute revisions.
Instance Method Summary collapse
- #<<(object) ⇒ Object
- #append_subobj(root, objset) ⇒ Object
- #Catalog ⇒ Object
-
#initialize ⇒ FDF
constructor
:nodoc:.
- #objects ⇒ Object
- #save(filename) ⇒ Object (also: #saveas)
Constructor Details
Instance Attribute Details
#header ⇒ Object
Returns the value of attribute header.
104 105 106 |
# File 'lib/origami/extensions/fdf.rb', line 104 def header @header end |
#revisions ⇒ Object
Returns the value of attribute revisions.
104 105 106 |
# File 'lib/origami/extensions/fdf.rb', line 104 def revisions @revisions end |
Instance Method Details
#<<(object) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/origami/extensions/fdf.rb', line 132 def <<(object) object.set_indirect(true) if object.no.zero? maxno = 1 while get_object(maxno) do maxno = maxno.succ end object.generation = 0 object.no = maxno end @revisions.first.body[object.reference] = object object.reference end |
#append_subobj(root, objset) ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/origami/extensions/fdf.rb', line 113 def append_subobj(root, objset) if objset.find{ |o| o.object_id == root.object_id }.nil? objset << root if root.is_a?(Array) or root.is_a?(Dictionary) root.each { |subobj| append_subobj(subobj, objset) unless subobj.is_a?(Reference) } end end end |
#Catalog ⇒ Object
149 150 151 |
# File 'lib/origami/extensions/fdf.rb', line 149 def Catalog get_object(@trailer.Root) end |
#objects ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/origami/extensions/fdf.rb', line 112 def objects def append_subobj(root, objset) if objset.find{ |o| o.object_id == root.object_id }.nil? objset << root if root.is_a?(Array) or root.is_a?(Dictionary) root.each { |subobj| append_subobj(subobj, objset) unless subobj.is_a?(Reference) } end end end objset = [] @revisions.first.body.values.each do |object| unless object.is_a?(Reference) append_subobj(object, objset) end end objset end |
#save(filename) ⇒ Object Also known as: saveas
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/origami/extensions/fdf.rb', line 153 def save(filename) bin = "" bin << @header.to_s lastno, brange = 0, 0 xrefs = [ XRef.new(0, XRef::LASTFREE, 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 bin << obj.to_s } xrefsection << XRef::Subsection.new(brange, xrefs) @xreftable = xrefsection @trailer ||= Trailer.new @trailer.Size = rev.body.size + 1 @trailer.startxref = bin.size bin << @xreftable.to_s bin << @trailer.to_s fd = File.open(filename, "w").binmode fd << bin fd.close show_entries end |