origami-docspring 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/examples/attachments/attachment.rb +7 -8
- data/examples/attachments/nested_document.rb +6 -5
- data/examples/encryption/encryption.rb +5 -4
- data/examples/events/events.rb +7 -6
- data/examples/flash/flash.rb +10 -9
- data/examples/forms/javascript.rb +14 -13
- data/examples/forms/xfa.rb +67 -66
- data/examples/javascript/hello_world.rb +6 -5
- data/examples/javascript/js_emulation.rb +26 -26
- data/examples/loop/goto.rb +12 -11
- data/examples/loop/named.rb +17 -16
- data/examples/signature/signature.rb +11 -11
- data/examples/uri/javascript.rb +25 -24
- data/examples/uri/open-uri.rb +5 -4
- data/examples/uri/submitform.rb +11 -10
- data/lib/origami/3d.rb +330 -334
- data/lib/origami/acroform.rb +267 -268
- data/lib/origami/actions.rb +266 -278
- data/lib/origami/annotations.rb +659 -670
- data/lib/origami/array.rb +192 -196
- data/lib/origami/boolean.rb +66 -70
- data/lib/origami/catalog.rb +360 -363
- data/lib/origami/collections.rb +132 -133
- data/lib/origami/compound.rb +125 -129
- data/lib/origami/destinations.rb +226 -237
- data/lib/origami/dictionary.rb +155 -154
- data/lib/origami/encryption.rb +967 -923
- data/lib/origami/extensions/fdf.rb +270 -275
- data/lib/origami/extensions/ppklite.rb +323 -328
- data/lib/origami/filespec.rb +170 -173
- data/lib/origami/filters/ascii.rb +162 -167
- data/lib/origami/filters/ccitt/tables.rb +248 -252
- data/lib/origami/filters/ccitt.rb +309 -312
- data/lib/origami/filters/crypt.rb +31 -34
- data/lib/origami/filters/dct.rb +47 -50
- data/lib/origami/filters/flate.rb +57 -60
- data/lib/origami/filters/jbig2.rb +50 -53
- data/lib/origami/filters/jpx.rb +40 -43
- data/lib/origami/filters/lzw.rb +151 -155
- data/lib/origami/filters/predictors.rb +250 -255
- data/lib/origami/filters/runlength.rb +111 -115
- data/lib/origami/filters.rb +319 -325
- data/lib/origami/font.rb +173 -177
- data/lib/origami/functions.rb +62 -66
- data/lib/origami/graphics/colors.rb +203 -208
- data/lib/origami/graphics/instruction.rb +79 -81
- data/lib/origami/graphics/path.rb +141 -144
- data/lib/origami/graphics/patterns.rb +156 -160
- data/lib/origami/graphics/render.rb +51 -47
- data/lib/origami/graphics/state.rb +144 -142
- data/lib/origami/graphics/text.rb +185 -188
- data/lib/origami/graphics/xobject.rb +818 -804
- data/lib/origami/graphics.rb +25 -26
- data/lib/origami/header.rb +63 -65
- data/lib/origami/javascript.rb +718 -651
- data/lib/origami/linearization.rb +284 -285
- data/lib/origami/metadata.rb +156 -135
- data/lib/origami/name.rb +98 -100
- data/lib/origami/null.rb +49 -51
- data/lib/origami/numeric.rb +133 -135
- data/lib/origami/obfuscation.rb +180 -182
- data/lib/origami/object.rb +634 -631
- data/lib/origami/optionalcontent.rb +147 -149
- data/lib/origami/outline.rb +46 -48
- data/lib/origami/outputintents.rb +76 -77
- data/lib/origami/page.rb +637 -596
- data/lib/origami/parser.rb +214 -221
- data/lib/origami/parsers/fdf.rb +44 -45
- data/lib/origami/parsers/pdf/lazy.rb +147 -154
- data/lib/origami/parsers/pdf/linear.rb +104 -109
- data/lib/origami/parsers/pdf.rb +109 -107
- data/lib/origami/parsers/ppklite.rb +44 -46
- data/lib/origami/pdf.rb +886 -896
- data/lib/origami/reference.rb +116 -120
- data/lib/origami/signature.rb +617 -625
- data/lib/origami/stream.rb +560 -558
- data/lib/origami/string.rb +366 -368
- data/lib/origami/template/patterns.rb +50 -52
- data/lib/origami/template/widgets.rb +111 -114
- data/lib/origami/trailer.rb +153 -157
- data/lib/origami/tree.rb +55 -57
- data/lib/origami/version.rb +19 -19
- data/lib/origami/webcapture.rb +87 -90
- data/lib/origami/xfa/config.rb +409 -414
- data/lib/origami/xfa/connectionset.rb +113 -117
- data/lib/origami/xfa/datasets.rb +38 -42
- data/lib/origami/xfa/localeset.rb +33 -37
- data/lib/origami/xfa/package.rb +49 -52
- data/lib/origami/xfa/pdf.rb +54 -59
- data/lib/origami/xfa/signature.rb +33 -37
- data/lib/origami/xfa/sourceset.rb +34 -38
- data/lib/origami/xfa/stylesheet.rb +35 -39
- data/lib/origami/xfa/template.rb +1630 -1634
- data/lib/origami/xfa/xdc.rb +33 -37
- data/lib/origami/xfa/xfa.rb +132 -123
- data/lib/origami/xfa/xfdf.rb +34 -38
- data/lib/origami/xfa/xmpmeta.rb +34 -38
- data/lib/origami/xfa.rb +50 -53
- data/lib/origami/xreftable.rb +462 -462
- data/lib/origami.rb +37 -38
- data/test/test_actions.rb +22 -20
- data/test/test_annotations.rb +54 -52
- data/test/test_forms.rb +23 -21
- data/test/test_native_types.rb +82 -78
- data/test/test_object_tree.rb +25 -24
- data/test/test_pages.rb +43 -41
- data/test/test_pdf.rb +2 -0
- data/test/test_pdf_attachment.rb +23 -21
- data/test/test_pdf_create.rb +16 -15
- data/test/test_pdf_encrypt.rb +69 -66
- data/test/test_pdf_parse.rb +131 -129
- data/test/test_pdf_parse_lazy.rb +53 -53
- data/test/test_pdf_sign.rb +67 -67
- data/test/test_streams.rb +145 -143
- data/test/test_xrefs.rb +46 -45
- metadata +64 -8
data/lib/origami/parser.rb
CHANGED
@@ -1,269 +1,262 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# This file is part of Origami, PDF manipulation framework for Ruby
|
5
|
+
# Copyright (C) 2016 Guillaume Delugré.
|
6
|
+
#
|
7
|
+
# Origami is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# Origami is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
20
|
|
21
21
|
require 'colorize'
|
22
22
|
require 'strscan'
|
23
23
|
|
24
24
|
module Origami
|
25
|
+
class Parser # :nodoc:
|
26
|
+
class ParsingError < Error # :nodoc:
|
27
|
+
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
@options.update(options)
|
68
|
-
@logger = @options[:logger]
|
69
|
-
@data = nil
|
70
|
-
end
|
29
|
+
#
|
30
|
+
# Do not output debug information.
|
31
|
+
#
|
32
|
+
VERBOSE_QUIET = 0
|
33
|
+
|
34
|
+
#
|
35
|
+
# Output some useful information.
|
36
|
+
#
|
37
|
+
VERBOSE_INFO = 1
|
38
|
+
|
39
|
+
#
|
40
|
+
# Output debug information.
|
41
|
+
#
|
42
|
+
VERBOSE_DEBUG = 2
|
43
|
+
|
44
|
+
#
|
45
|
+
# Output every objects read
|
46
|
+
#
|
47
|
+
VERBOSE_TRACE = 3
|
48
|
+
|
49
|
+
attr_accessor :options
|
50
|
+
|
51
|
+
def initialize(options = {}) # :nodoc:
|
52
|
+
# Type information for indirect objects.
|
53
|
+
@deferred_casts = {}
|
54
|
+
|
55
|
+
# Default options values
|
56
|
+
@options =
|
57
|
+
{
|
58
|
+
verbosity: VERBOSE_INFO, # Verbose level.
|
59
|
+
ignore_errors: true, # Try to keep on parsing when errors occur.
|
60
|
+
callback: proc {}, # Callback procedure whenever a structure is read.
|
61
|
+
logger: $stderr, # Where to output parser messages.
|
62
|
+
colorize_log: true # Colorize parser output?
|
63
|
+
}
|
64
|
+
|
65
|
+
@options.update(options)
|
66
|
+
@logger = @options[:logger]
|
67
|
+
@data = nil
|
68
|
+
end
|
71
69
|
|
72
|
-
|
73
|
-
|
70
|
+
def pos
|
71
|
+
raise "Cannot get position, parser has no loaded data." if @data.nil?
|
74
72
|
|
75
|
-
|
76
|
-
|
73
|
+
@data.pos
|
74
|
+
end
|
77
75
|
|
78
|
-
|
79
|
-
|
76
|
+
def pos=(offset)
|
77
|
+
raise "Cannot set position, parser has no loaded data." if @data.nil?
|
80
78
|
|
81
|
-
|
82
|
-
|
79
|
+
@data.pos = offset
|
80
|
+
end
|
83
81
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
@data = data
|
98
|
-
@data.pos = 0
|
82
|
+
def parse(stream)
|
83
|
+
data =
|
84
|
+
if stream.respond_to? :read
|
85
|
+
StringScanner.new(stream.read.force_encoding('binary'))
|
86
|
+
elsif stream.is_a? ::String
|
87
|
+
@filename = stream
|
88
|
+
StringScanner.new(File.binread(@filename))
|
89
|
+
elsif stream.is_a? StringScanner
|
90
|
+
stream
|
91
|
+
else
|
92
|
+
raise TypeError
|
99
93
|
end
|
100
94
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
begin
|
105
|
-
obj = Object.parse(@data, self)
|
106
|
-
return if obj.nil?
|
107
|
-
|
108
|
-
obj = try_object_promotion(obj)
|
109
|
-
trace "Read #{obj.type} object, #{obj.reference}"
|
110
|
-
|
111
|
-
@options[:callback].call(obj)
|
112
|
-
obj
|
113
|
-
|
114
|
-
rescue UnterminatedObjectError
|
115
|
-
error $!.message
|
116
|
-
obj = $!.obj
|
117
|
-
|
118
|
-
Object.skip_until_next_obj(@data)
|
119
|
-
@options[:callback].call(obj)
|
120
|
-
obj
|
121
|
-
|
122
|
-
rescue
|
123
|
-
error "Breaking on: #{(@data.peek(10) + "...").inspect} at offset 0x#{@data.pos.to_s(16)}"
|
124
|
-
error "Last exception: [#{$!.class}] #{$!.message}"
|
125
|
-
if not @options[:ignore_errors]
|
126
|
-
error "Manually fix the file or set :ignore_errors parameter."
|
127
|
-
raise
|
128
|
-
end
|
129
|
-
|
130
|
-
debug 'Skipping this indirect object.'
|
131
|
-
raise if not Object.skip_until_next_obj(@data)
|
95
|
+
@data = data
|
96
|
+
@data.pos = 0
|
97
|
+
end
|
132
98
|
|
133
|
-
|
134
|
-
|
99
|
+
def parse_object(pos = @data.pos) # :nodoc:
|
100
|
+
@data.pos = pos
|
101
|
+
|
102
|
+
begin
|
103
|
+
obj = Object.parse(@data, self)
|
104
|
+
return if obj.nil?
|
105
|
+
|
106
|
+
obj = try_object_promotion(obj)
|
107
|
+
trace "Read #{obj.type} object, #{obj.reference}"
|
108
|
+
|
109
|
+
@options[:callback].call(obj)
|
110
|
+
obj
|
111
|
+
rescue UnterminatedObjectError
|
112
|
+
error $!.message
|
113
|
+
obj = $!.obj
|
114
|
+
|
115
|
+
Object.skip_until_next_obj(@data)
|
116
|
+
@options[:callback].call(obj)
|
117
|
+
obj
|
118
|
+
rescue
|
119
|
+
error "Breaking on: #{(@data.peek(10) + "...").inspect} at offset 0x#{@data.pos.to_s(16)}"
|
120
|
+
error "Last exception: [#{$!.class}] #{$!.message}"
|
121
|
+
if !@options[:ignore_errors]
|
122
|
+
error "Manually fix the file or set :ignore_errors parameter."
|
123
|
+
raise
|
135
124
|
end
|
136
125
|
|
137
|
-
|
138
|
-
|
126
|
+
debug 'Skipping this indirect object.'
|
127
|
+
raise if !Object.skip_until_next_obj(@data)
|
139
128
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
@options[:callback].call(xreftable)
|
129
|
+
retry
|
130
|
+
end
|
131
|
+
end
|
144
132
|
|
145
|
-
|
133
|
+
def parse_xreftable(pos = @data.pos) # :nodoc:
|
134
|
+
@data.pos = pos
|
146
135
|
|
147
|
-
|
148
|
-
|
149
|
-
|
136
|
+
begin
|
137
|
+
info "...Parsing xref table..."
|
138
|
+
xreftable = XRef::Section.parse(@data)
|
139
|
+
@options[:callback].call(xreftable)
|
150
140
|
|
151
|
-
|
141
|
+
xreftable
|
142
|
+
rescue
|
143
|
+
debug "Exception caught while parsing xref table : " + $!.message
|
144
|
+
warn "Unable to parse xref table! Xrefs might be stored into an XRef stream."
|
152
145
|
|
153
|
-
|
154
|
-
end
|
155
|
-
end
|
146
|
+
@data.pos -= 'trailer'.length unless @data.skip_until(/trailer/).nil?
|
156
147
|
|
157
|
-
|
158
|
-
|
148
|
+
nil
|
149
|
+
end
|
150
|
+
end
|
159
151
|
|
160
|
-
|
161
|
-
|
162
|
-
trailer = Trailer.parse(@data, self)
|
152
|
+
def parse_trailer(pos = @data.pos) # :nodoc:
|
153
|
+
@data.pos = pos
|
163
154
|
|
164
|
-
|
165
|
-
|
155
|
+
begin
|
156
|
+
info "...Parsing trailer..."
|
157
|
+
trailer = Trailer.parse(@data, self)
|
166
158
|
|
167
|
-
|
168
|
-
|
169
|
-
|
159
|
+
@options[:callback].call(trailer)
|
160
|
+
trailer
|
161
|
+
rescue
|
162
|
+
debug "Exception caught while parsing trailer : " + $!.message
|
163
|
+
warn "Unable to parse trailer!"
|
170
164
|
|
171
|
-
|
172
|
-
|
173
|
-
|
165
|
+
raise
|
166
|
+
end
|
167
|
+
end
|
174
168
|
|
175
|
-
|
176
|
-
|
177
|
-
|
169
|
+
def defer_type_cast(reference, type) # :nodoc:
|
170
|
+
@deferred_casts[reference] = type
|
171
|
+
end
|
178
172
|
|
179
|
-
|
180
|
-
|
181
|
-
|
173
|
+
def target_filename
|
174
|
+
@filename
|
175
|
+
end
|
182
176
|
|
183
|
-
|
184
|
-
|
185
|
-
|
177
|
+
def target_filesize
|
178
|
+
@data&.string&.size
|
179
|
+
end
|
186
180
|
|
187
|
-
|
188
|
-
|
189
|
-
|
181
|
+
def target_data
|
182
|
+
@data.string.dup if @data
|
183
|
+
end
|
190
184
|
|
191
|
-
|
192
|
-
|
193
|
-
|
185
|
+
def error(msg = "") # :nodoc:
|
186
|
+
log(VERBOSE_QUIET, 'error', :red, msg)
|
187
|
+
end
|
194
188
|
|
195
|
-
|
196
|
-
|
197
|
-
|
189
|
+
def warn(msg = "") # :nodoc:
|
190
|
+
log(VERBOSE_INFO, 'warn ', :yellow, msg)
|
191
|
+
end
|
198
192
|
|
199
|
-
|
200
|
-
|
201
|
-
|
193
|
+
def info(msg = "") # :nodoc:
|
194
|
+
log(VERBOSE_INFO, 'info ', :green, msg)
|
195
|
+
end
|
202
196
|
|
203
|
-
|
204
|
-
|
205
|
-
|
197
|
+
def debug(msg = "") # :nodoc:
|
198
|
+
log(VERBOSE_DEBUG, 'debug', :magenta, msg)
|
199
|
+
end
|
206
200
|
|
207
|
-
|
208
|
-
|
209
|
-
|
201
|
+
def trace(msg = "") # :nodoc:
|
202
|
+
log(VERBOSE_TRACE, 'trace', :cyan, msg)
|
203
|
+
end
|
210
204
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
205
|
+
def self.init_scanner(stream)
|
206
|
+
if stream.is_a?(StringScanner)
|
207
|
+
stream
|
208
|
+
elsif stream.respond_to?(:to_str)
|
209
|
+
StringScanner.new(stream.to_str)
|
210
|
+
else
|
211
|
+
raise TypeError, "Cannot initialize scanner from #{stream.class}"
|
212
|
+
end
|
213
|
+
end
|
220
214
|
|
221
|
-
|
215
|
+
private
|
222
216
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
217
|
+
#
|
218
|
+
# Attempt to promote an object using the deferred casts.
|
219
|
+
#
|
220
|
+
def try_object_promotion(obj)
|
221
|
+
return obj unless Origami::OPTIONS[:enable_type_propagation] && @deferred_casts.key?(obj.reference)
|
228
222
|
|
229
|
-
|
230
|
-
|
223
|
+
types = @deferred_casts[obj.reference]
|
224
|
+
types = [types] unless types.is_a?(::Array)
|
231
225
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
226
|
+
# Promote object if a compatible type is found.
|
227
|
+
cast_type = types.find { |type| type < obj.class }
|
228
|
+
if cast_type
|
229
|
+
obj = obj.cast_to(cast_type, self)
|
230
|
+
else
|
231
|
+
obj
|
232
|
+
end
|
233
|
+
end
|
240
234
|
|
241
|
-
|
242
|
-
|
235
|
+
def log(level, prefix, color, message) # :nodoc:
|
236
|
+
return unless @options[:verbosity] >= level
|
243
237
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
238
|
+
if @options[:colorize_log]
|
239
|
+
@logger.print "[#{prefix}] ".colorize(color)
|
240
|
+
@logger.puts message
|
241
|
+
else
|
242
|
+
@logger.puts "[#{prefix}] #{message}"
|
243
|
+
end
|
244
|
+
end
|
251
245
|
|
252
|
-
|
253
|
-
|
246
|
+
def propagate_types(document)
|
247
|
+
info "...Propagating types..."
|
254
248
|
|
255
|
-
|
256
|
-
|
257
|
-
|
249
|
+
current_state = nil
|
250
|
+
until current_state == @deferred_casts
|
251
|
+
current_state = @deferred_casts.clone
|
258
252
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
end
|
265
|
-
end
|
253
|
+
current_state.each_pair do |ref, type|
|
254
|
+
type = [type] unless type.is_a?(::Array)
|
255
|
+
type.each do |hint|
|
256
|
+
break if document.cast_object(ref, hint)
|
257
|
+
end
|
266
258
|
end
|
259
|
+
end
|
267
260
|
end
|
268
|
-
|
261
|
+
end
|
269
262
|
end
|
data/lib/origami/parsers/fdf.rb
CHANGED
@@ -1,56 +1,55 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# This file is part of Origami, PDF manipulation framework for Ruby
|
5
|
+
# Copyright (C) 2016 Guillaume Delugré.
|
6
|
+
#
|
7
|
+
# Origami is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# Origami is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
20
|
|
21
21
|
require 'origami/parser'
|
22
22
|
|
23
23
|
module Origami
|
24
|
+
class FDF
|
25
|
+
class Parser < Origami::Parser
|
26
|
+
def parse(stream) # :nodoc:
|
27
|
+
super
|
28
|
+
|
29
|
+
fdf = FDF.new(self)
|
30
|
+
fdf.header = FDF::Header.parse(@data)
|
31
|
+
@options[:callback].call(fdf.header)
|
32
|
+
|
33
|
+
loop do
|
34
|
+
break if (object = parse_object).nil?
|
35
|
+
fdf.insert(object)
|
36
|
+
end
|
24
37
|
|
25
|
-
|
26
|
-
|
27
|
-
def parse(stream) #:nodoc:
|
28
|
-
super(stream)
|
29
|
-
|
30
|
-
fdf = FDF.new(self)
|
31
|
-
fdf.header = FDF::Header.parse(@data)
|
32
|
-
@options[:callback].call(fdf.header)
|
33
|
-
|
34
|
-
loop do
|
35
|
-
break if (object = parse_object).nil?
|
36
|
-
fdf.insert(object)
|
37
|
-
end
|
38
|
-
|
39
|
-
fdf.revisions.first.xreftable = parse_xreftable
|
40
|
-
fdf.revisions.first.trailer = parse_trailer
|
41
|
-
|
42
|
-
if Origami::OPTIONS[:enable_type_propagation]
|
43
|
-
trailer = fdf.revisions.first.trailer
|
38
|
+
fdf.revisions.first.xreftable = parse_xreftable
|
39
|
+
fdf.revisions.first.trailer = parse_trailer
|
44
40
|
|
45
|
-
|
46
|
-
|
47
|
-
end
|
41
|
+
if Origami::OPTIONS[:enable_type_propagation]
|
42
|
+
trailer = fdf.revisions.first.trailer
|
48
43
|
|
49
|
-
|
50
|
-
|
44
|
+
if trailer[:Root].is_a?(Reference)
|
45
|
+
fdf.cast_object(trailer[:Root], FDF::Catalog)
|
46
|
+
end
|
51
47
|
|
52
|
-
|
53
|
-
end
|
48
|
+
propagate_types(fdf)
|
54
49
|
end
|
50
|
+
|
51
|
+
fdf
|
52
|
+
end
|
55
53
|
end
|
54
|
+
end
|
56
55
|
end
|