origamindee 3.0.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 +7 -0
- data/CHANGELOG.md +89 -0
- data/COPYING.LESSER +165 -0
- data/README.md +131 -0
- data/bin/config/pdfcop.conf.yml +236 -0
- data/bin/pdf2pdfa +87 -0
- data/bin/pdf2ruby +333 -0
- data/bin/pdfcop +476 -0
- data/bin/pdfdecompress +97 -0
- data/bin/pdfdecrypt +91 -0
- data/bin/pdfencrypt +113 -0
- data/bin/pdfexplode +223 -0
- data/bin/pdfextract +277 -0
- data/bin/pdfmetadata +143 -0
- data/bin/pdfsh +12 -0
- data/bin/shell/console.rb +128 -0
- data/bin/shell/hexdump.rb +59 -0
- data/bin/shell/irbrc +69 -0
- data/examples/README.md +34 -0
- data/examples/attachments/attachment.rb +38 -0
- data/examples/attachments/nested_document.rb +51 -0
- data/examples/encryption/encryption.rb +28 -0
- data/examples/events/events.rb +72 -0
- data/examples/flash/flash.rb +37 -0
- data/examples/flash/helloworld.swf +0 -0
- data/examples/forms/javascript.rb +54 -0
- data/examples/forms/xfa.rb +115 -0
- data/examples/javascript/hello_world.rb +22 -0
- data/examples/javascript/js_emulation.rb +54 -0
- data/examples/loop/goto.rb +32 -0
- data/examples/loop/named.rb +33 -0
- data/examples/signature/signature.rb +65 -0
- data/examples/uri/javascript.rb +56 -0
- data/examples/uri/open-uri.rb +21 -0
- data/examples/uri/submitform.rb +47 -0
- data/lib/origami/3d.rb +364 -0
- data/lib/origami/acroform.rb +321 -0
- data/lib/origami/actions.rb +318 -0
- data/lib/origami/annotations.rb +711 -0
- data/lib/origami/array.rb +242 -0
- data/lib/origami/boolean.rb +90 -0
- data/lib/origami/catalog.rb +418 -0
- data/lib/origami/collections.rb +144 -0
- data/lib/origami/compound.rb +161 -0
- data/lib/origami/destinations.rb +252 -0
- data/lib/origami/dictionary.rb +192 -0
- data/lib/origami/encryption.rb +1084 -0
- data/lib/origami/extensions/fdf.rb +347 -0
- data/lib/origami/extensions/ppklite.rb +422 -0
- data/lib/origami/filespec.rb +197 -0
- data/lib/origami/filters/ascii.rb +211 -0
- data/lib/origami/filters/ccitt/tables.rb +267 -0
- data/lib/origami/filters/ccitt.rb +357 -0
- data/lib/origami/filters/crypt.rb +38 -0
- data/lib/origami/filters/dct.rb +54 -0
- data/lib/origami/filters/flate.rb +69 -0
- data/lib/origami/filters/jbig2.rb +57 -0
- data/lib/origami/filters/jpx.rb +47 -0
- data/lib/origami/filters/lzw.rb +170 -0
- data/lib/origami/filters/predictors.rb +292 -0
- data/lib/origami/filters/runlength.rb +129 -0
- data/lib/origami/filters.rb +364 -0
- data/lib/origami/font.rb +196 -0
- data/lib/origami/functions.rb +79 -0
- data/lib/origami/graphics/colors.rb +230 -0
- data/lib/origami/graphics/instruction.rb +98 -0
- data/lib/origami/graphics/path.rb +182 -0
- data/lib/origami/graphics/patterns.rb +174 -0
- data/lib/origami/graphics/render.rb +62 -0
- data/lib/origami/graphics/state.rb +149 -0
- data/lib/origami/graphics/text.rb +225 -0
- data/lib/origami/graphics/xobject.rb +918 -0
- data/lib/origami/graphics.rb +38 -0
- data/lib/origami/header.rb +75 -0
- data/lib/origami/javascript.rb +713 -0
- data/lib/origami/linearization.rb +330 -0
- data/lib/origami/metadata.rb +172 -0
- data/lib/origami/name.rb +135 -0
- data/lib/origami/null.rb +65 -0
- data/lib/origami/numeric.rb +181 -0
- data/lib/origami/obfuscation.rb +245 -0
- data/lib/origami/object.rb +760 -0
- data/lib/origami/optionalcontent.rb +183 -0
- data/lib/origami/outline.rb +54 -0
- data/lib/origami/outputintents.rb +85 -0
- data/lib/origami/page.rb +722 -0
- data/lib/origami/parser.rb +269 -0
- data/lib/origami/parsers/fdf.rb +56 -0
- data/lib/origami/parsers/pdf/lazy.rb +176 -0
- data/lib/origami/parsers/pdf/linear.rb +122 -0
- data/lib/origami/parsers/pdf.rb +118 -0
- data/lib/origami/parsers/ppklite.rb +57 -0
- data/lib/origami/pdf.rb +1108 -0
- data/lib/origami/reference.rb +134 -0
- data/lib/origami/signature.rb +702 -0
- data/lib/origami/stream.rb +705 -0
- data/lib/origami/string.rb +444 -0
- data/lib/origami/template/patterns.rb +56 -0
- data/lib/origami/template/widgets.rb +151 -0
- data/lib/origami/trailer.rb +190 -0
- data/lib/origami/tree.rb +62 -0
- data/lib/origami/version.rb +23 -0
- data/lib/origami/webcapture.rb +100 -0
- data/lib/origami/xfa/config.rb +453 -0
- data/lib/origami/xfa/connectionset.rb +146 -0
- data/lib/origami/xfa/datasets.rb +49 -0
- data/lib/origami/xfa/localeset.rb +42 -0
- data/lib/origami/xfa/package.rb +59 -0
- data/lib/origami/xfa/pdf.rb +73 -0
- data/lib/origami/xfa/signature.rb +42 -0
- data/lib/origami/xfa/sourceset.rb +43 -0
- data/lib/origami/xfa/stylesheet.rb +44 -0
- data/lib/origami/xfa/template.rb +1691 -0
- data/lib/origami/xfa/xdc.rb +42 -0
- data/lib/origami/xfa/xfa.rb +146 -0
- data/lib/origami/xfa/xfdf.rb +43 -0
- data/lib/origami/xfa/xmpmeta.rb +43 -0
- data/lib/origami/xfa.rb +62 -0
- data/lib/origami/xreftable.rb +557 -0
- data/lib/origami.rb +47 -0
- data/test/dataset/calc.pdf +85 -0
- data/test/dataset/crypto.pdf +36 -0
- data/test/dataset/empty.pdf +49 -0
- data/test/test_actions.rb +27 -0
- data/test/test_annotations.rb +68 -0
- data/test/test_forms.rb +30 -0
- data/test/test_native_types.rb +83 -0
- data/test/test_object_tree.rb +33 -0
- data/test/test_pages.rb +60 -0
- data/test/test_pdf.rb +20 -0
- data/test/test_pdf_attachment.rb +34 -0
- data/test/test_pdf_create.rb +24 -0
- data/test/test_pdf_encrypt.rb +102 -0
- data/test/test_pdf_parse.rb +134 -0
- data/test/test_pdf_parse_lazy.rb +69 -0
- data/test/test_pdf_sign.rb +97 -0
- data/test/test_streams.rb +184 -0
- data/test/test_xrefs.rb +67 -0
- metadata +280 -0
data/lib/origami/3d.rb
ADDED
@@ -0,0 +1,364 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
This file is part of Origami, PDF manipulation framework for Ruby
|
4
|
+
Copyright (C) 2016 Guillaume Delugré.
|
5
|
+
|
6
|
+
Origami is free software: you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
Origami is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU Lesser General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU Lesser General Public License
|
17
|
+
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
=end
|
20
|
+
|
21
|
+
module Origami
|
22
|
+
|
23
|
+
class Projection3D < Dictionary
|
24
|
+
include StandardObject
|
25
|
+
|
26
|
+
ORTHOGRAPHIC = :O
|
27
|
+
PERSPECTIVE = :P
|
28
|
+
|
29
|
+
module ClippingStyles
|
30
|
+
EXPLICIT_NEARFAR = :XNF
|
31
|
+
AUTOMATIC_NEARFAR = :ANF
|
32
|
+
end
|
33
|
+
|
34
|
+
module Scaling
|
35
|
+
WIDTH = :W
|
36
|
+
HEIGHT = :H
|
37
|
+
MINIMUM = :Min
|
38
|
+
MAXIMUM = :Max
|
39
|
+
ABSOLUTE = :Absolute
|
40
|
+
end
|
41
|
+
|
42
|
+
field :Subtype, :Type => Name, :Default => ORTHOGRAPHIC
|
43
|
+
field :CS, :Type => Name, :Default => ClippingStyles::AUTOMATIC_NEARFAR
|
44
|
+
field :F, :Type => Number
|
45
|
+
field :N, :Type => Number
|
46
|
+
field :FOV, :Type => Number
|
47
|
+
field :PS, :Type => [ Number, Name ], :Default => Scaling::WIDTH
|
48
|
+
field :OS, :Type => Number, :Default => 1
|
49
|
+
field :OB, :Type => Name, :Version => "1.7", :Default => Scaling::ABSOLUTE
|
50
|
+
end
|
51
|
+
|
52
|
+
class Background3D < Dictionary
|
53
|
+
include StandardObject
|
54
|
+
|
55
|
+
field :Type, :Type => Name, :Default => :"3DBG"
|
56
|
+
field :Subtype, :Type => Name, :Default => :SC
|
57
|
+
field :CS, :Type => [ Name, Array ], :Default => Graphics::Color::Space::DEVICE_RGB
|
58
|
+
field :C, :Type => Object, :Default => [ 1, 1, 1 ]
|
59
|
+
field :EA, :Type => Boolean, :Default => false
|
60
|
+
end
|
61
|
+
|
62
|
+
class RenderMode3D < Dictionary
|
63
|
+
include StandardObject
|
64
|
+
|
65
|
+
module Modes
|
66
|
+
SOLID = :Solid
|
67
|
+
SOLID_WIREFRAME = :SolidWireFrame
|
68
|
+
TRANSPARENT = :Transparent
|
69
|
+
TRANSPARENT_WIREFRAME = :TransparentWireFrame
|
70
|
+
BOUNDINGBOX = :BoundingBox
|
71
|
+
TRANSPARENT_BOUNDINGBOX = :TransparentBoundingBox
|
72
|
+
TRANSPARENT_BOUNDINGBOX_OUTLINE = :TransparentBoundingBoxOutline
|
73
|
+
WIREFRAME = :WireFrame
|
74
|
+
SHADED_WIREFRAME = :ShadedWireFrame
|
75
|
+
HIDDEN_WIREFRAME = :HiddenWireFrame
|
76
|
+
VERTICES = :Vertices
|
77
|
+
SHADED_VERTICES = :ShadedVertices
|
78
|
+
ILLUSTRATION = :Illustration
|
79
|
+
SOLID_OUTLINE = :SolidOutline
|
80
|
+
SHADED_ILLUSTRATION = :ShadedIllustration
|
81
|
+
end
|
82
|
+
|
83
|
+
field :Type, :Type => Name, :Default => :"3DRenderMode"
|
84
|
+
field :Subtype, :Type => Name, :Required => true, :Version => "1.7"
|
85
|
+
field :AC, :Type => Array, :Default => [ Graphics::Color::Space::DEVICE_RGB, 0, 0, 0]
|
86
|
+
field :BG, :Type => [ Name, Array ], :Default => :BG
|
87
|
+
field :O, :Type => Number, :Default => 0.5
|
88
|
+
field :CV, :Type => Number, :Default => 45
|
89
|
+
end
|
90
|
+
|
91
|
+
class LightingScheme3D < Dictionary
|
92
|
+
include StandardObject
|
93
|
+
|
94
|
+
module Styles
|
95
|
+
ARTWORK = :Artwork
|
96
|
+
NONE = :None
|
97
|
+
WHITE = :White
|
98
|
+
DAY = :Day
|
99
|
+
NIGHT = :Night
|
100
|
+
HARD = :Hard
|
101
|
+
PRIMARY = :Primary
|
102
|
+
BLUE = :Blue
|
103
|
+
RED = :Red
|
104
|
+
CUBE = :Cube
|
105
|
+
CAD = :CAD
|
106
|
+
HEADLAMP = :HeadLamp
|
107
|
+
end
|
108
|
+
|
109
|
+
field :Type, :Type => Name, :Default => :"3DLightingScheme"
|
110
|
+
field :Subtype, :Type => Name, :Version => "1.7", :Required => true
|
111
|
+
end
|
112
|
+
|
113
|
+
class CrossSection3D < Dictionary
|
114
|
+
include StandardObject
|
115
|
+
|
116
|
+
field :Type, :Type => Name, :Default => :"3DCrossSection"
|
117
|
+
field :C, :Type => Array, :Default => [ 0, 0, 0 ]
|
118
|
+
field :O, :Type => Array, :Version => "1.7", :Default => [ Null.new, 0, 0 ], :Required => true
|
119
|
+
field :PO, :Type => Number, :Default => 0.5
|
120
|
+
field :PC, :Type => Array, :Default => [ Graphics::Color::Space::DEVICE_RGB, 1, 1, 1 ]
|
121
|
+
field :IV, :Type => Boolean, :Default => false
|
122
|
+
field :IC, :Type => Array, :Default => [ Graphics::Color::Space::DEVICE_RGB, 0, 1 ,0]
|
123
|
+
end
|
124
|
+
|
125
|
+
class Node3D < Dictionary
|
126
|
+
include StandardObject
|
127
|
+
|
128
|
+
field :Type, :Type => Name, :Default => :"3DNode"
|
129
|
+
field :N, :Type => String, :Version => "1.7", :Required => true
|
130
|
+
field :O, :Type => Number
|
131
|
+
field :V, :Type => Boolean
|
132
|
+
field :M, :Type => Array
|
133
|
+
end
|
134
|
+
|
135
|
+
class Measurement3D < Dictionary
|
136
|
+
include StandardObject
|
137
|
+
|
138
|
+
field :Type, :Type => Name, :Default => :"3DMeasure"
|
139
|
+
field :Subtype, :Type => Name, :Required => true
|
140
|
+
field :TRL, :Type => String
|
141
|
+
end
|
142
|
+
|
143
|
+
class LinearDimensionMeasurement3D < Measurement3D
|
144
|
+
field :Subtype, :Type => Name, :Default => :L3D, :Required => true
|
145
|
+
field :AP, :Type => Array.of(Number, length: 3), :Required => true
|
146
|
+
field :A1, :Type => Array.of(Number, length: 3), :Required => true
|
147
|
+
field :N1, :Type => String
|
148
|
+
field :A2, :Type => Array.of(Number, length: 3), :Required => true
|
149
|
+
field :N2, :Type => String
|
150
|
+
field :TP, :Type => Array.of(Number, length: 3), :Required => true
|
151
|
+
field :TY, :Type => Array.of(Number, length: 3), :Required => true
|
152
|
+
field :TS, :Type => Number
|
153
|
+
field :C, :Type => Array.of(Number, length: 3)
|
154
|
+
field :V, :Type => Number, :Required => true
|
155
|
+
field :U, :Type => String, :Required => true
|
156
|
+
field :P, :Type => Integer, :Default => 3
|
157
|
+
field :UT, :Type => String
|
158
|
+
field :S, :Type => Annotation::Projection
|
159
|
+
end
|
160
|
+
|
161
|
+
class PerpendicularDimensionMeasurement3D < Measurement3D
|
162
|
+
field :Subtype, :Type => Name, :Default => :PD3, :Required => true
|
163
|
+
field :AP, :Type => Array.of(Number, length: 3), :Required => true
|
164
|
+
field :A1, :Type => Array.of(Number, length: 3), :Required => true
|
165
|
+
field :N1, :Type => String
|
166
|
+
field :A2, :Type => Array.of(Number, length: 3), :Required => true
|
167
|
+
field :N2, :Type => String
|
168
|
+
field :D1, :Type => Array.of(Number, length: 3), :Required => true
|
169
|
+
field :TP, :Type => Array.of(Number, length: 3), :Required => true
|
170
|
+
field :TY, :Type => Array.of(Number, length: 3), :Required => true
|
171
|
+
field :TS, :Type => Number
|
172
|
+
field :C, :Type => Array.of(Number, length: 3)
|
173
|
+
field :V, :Type => Number, :Required => true
|
174
|
+
field :U, :Type => String, :Required => true
|
175
|
+
field :P, :Type => Integer, :Default => 3
|
176
|
+
field :UT, :Type => String
|
177
|
+
field :S, :Type => Annotation::Projection
|
178
|
+
end
|
179
|
+
|
180
|
+
class AngularDimensionMeasurement3D < Measurement3D
|
181
|
+
field :Subtype, :Type => Name, :Default => :AD3, :Required => true
|
182
|
+
field :AP, :Type => Array.of(Number, length: 3), :Required => true
|
183
|
+
field :A1, :Type => Array.of(Number, length: 3), :Required => true
|
184
|
+
field :D1, :Type => Array.of(Number, length: 3), :Required => true
|
185
|
+
field :N1, :Type => String
|
186
|
+
field :A2, :Type => Array.of(Number, length: 3), :Required => true
|
187
|
+
field :D2, :Type => Array.of(Number, length: 3), :Required => true
|
188
|
+
field :N2, :Type => String
|
189
|
+
field :TP, :Type => Array.of(Number, length: 3), :Required => true
|
190
|
+
field :TX, :Type => Array.of(Number, length: 3), :Required => true
|
191
|
+
field :TY, :Type => Array.of(Number, length: 3), :Required => true
|
192
|
+
field :TS, :Type => Number
|
193
|
+
field :C, :Type => Array.of(Number, length: 3)
|
194
|
+
field :V, :Type => Number, :Required => true
|
195
|
+
field :P, :Type => Integer, :Default => 3
|
196
|
+
field :UT, :Type => String
|
197
|
+
field :DR, :Type => Boolean, :Default => true
|
198
|
+
field :S, :Type => Annotation::Projection
|
199
|
+
end
|
200
|
+
|
201
|
+
class RadialMeasurement3D < Measurement3D
|
202
|
+
field :Subtype, :Type => Name, :Default => :RD3, :Required => true
|
203
|
+
field :AP, :Type => Array.of(Number, length: 3), :Required => true
|
204
|
+
field :A1, :Type => Array.of(Number, length: 3), :Required => true
|
205
|
+
field :A2, :Type => Array.of(Number, length: 3), :Required => true
|
206
|
+
field :N2, :Type => String
|
207
|
+
field :A3, :Type => Array.of(Number, length: 3), :Required => true
|
208
|
+
field :A4, :Type => Array.of(Number, length: 3), :Required => true
|
209
|
+
field :TP, :Type => Array.of(Number, length: 3), :Required => true
|
210
|
+
field :TX, :Type => Array.of(Number, length: 3), :Required => true
|
211
|
+
field :TY, :Type => Array.of(Number, length: 3), :Required => true
|
212
|
+
field :EL, :Type => Number, :Default => 60
|
213
|
+
field :TS, :Type => Number
|
214
|
+
field :C, :Type => Array.of(Number, length: 3)
|
215
|
+
field :V, :Type => Number, :Required => true
|
216
|
+
field :U, :Type => String, :Required => true
|
217
|
+
field :P, :Type => Integer, :Default => 3
|
218
|
+
field :UT, :Type => String
|
219
|
+
field :SC, :Type => Boolean, :Default => false
|
220
|
+
field :R, :Type => Boolean, :Default => true
|
221
|
+
field :S, :Type => Annotation::Projection
|
222
|
+
end
|
223
|
+
|
224
|
+
class CommentNote3D < Measurement3D
|
225
|
+
field :Subtype, :Type => Name, :Default => :"3DC", :Required => true
|
226
|
+
field :A1, :Type => Array.of(Number, length: 3), :Required => true
|
227
|
+
field :N1, :Type => String
|
228
|
+
field :TP, :Type => Array.of(Number, length: 3), :Required => true
|
229
|
+
field :TB, :Type => Array.of(Integer, length: 2)
|
230
|
+
field :TS, :Type => Number
|
231
|
+
field :C, :Type => Array.of(Number, length: 3)
|
232
|
+
field :UT, :Type => String
|
233
|
+
field :S, :Type => Annotation::Projection
|
234
|
+
end
|
235
|
+
|
236
|
+
class View3D < Dictionary
|
237
|
+
include StandardObject
|
238
|
+
|
239
|
+
field :Type, :Type => Name, :Default => :"3DView"
|
240
|
+
field :XN, :Type => String, :Required => true
|
241
|
+
field :IN, :Type => String
|
242
|
+
field :MS, :Type => Name
|
243
|
+
field :C2W, :Type => Array
|
244
|
+
field :U3DPath, :Type => [ String, Array.of(String) ]
|
245
|
+
field :CO, :Type => Number
|
246
|
+
field :P, :Type => Projection3D
|
247
|
+
field :O, :Type => Graphics::FormXObject
|
248
|
+
field :BG, :Type => Background3D
|
249
|
+
field :RM, :Type => RenderMode3D, :Version => "1.7"
|
250
|
+
field :LS, :Type => LightingScheme3D, :Version => "1.7"
|
251
|
+
field :SA, :Type => Array.of(CrossSection3D), :Version => "1.7"
|
252
|
+
field :NA, :Type => Array.of(Node3D), :Version => "1.7"
|
253
|
+
field :NR, :Type => Boolean, :Version => "1.7", :Default => false
|
254
|
+
end
|
255
|
+
|
256
|
+
class AnimationStyle3D < Dictionary
|
257
|
+
include StandardObject
|
258
|
+
|
259
|
+
module Styles
|
260
|
+
NONE = :None
|
261
|
+
LINEAR = :Linear
|
262
|
+
OSCILLATING = :Oscillating
|
263
|
+
end
|
264
|
+
|
265
|
+
field :Type, :Type => Name, :Default => :"3DAnimationStyle"
|
266
|
+
field :Subtype, :Type => Name, :Default => Styles::NONE
|
267
|
+
field :PC, :Type => Integer, :Default => 0
|
268
|
+
field :TM, :Type => Number, :Default => 1
|
269
|
+
end
|
270
|
+
|
271
|
+
class U3DStream < Stream
|
272
|
+
include StandardObject
|
273
|
+
|
274
|
+
module Type
|
275
|
+
U3D = :U3D
|
276
|
+
PRC = :PRC
|
277
|
+
end
|
278
|
+
|
279
|
+
field :Type, :Type => Name, :Default => :"3D"
|
280
|
+
field :Subtype, :Type => Name, :Default => Type::U3D, :Required => true, :Version => "1.7", :ExtensionLevel => 3
|
281
|
+
field :VA, :Type => Array.of(View3D)
|
282
|
+
field :DV, :Type => Object
|
283
|
+
field :Resources, :Type => Dictionary
|
284
|
+
field :OnInstantiate, :Type => Stream
|
285
|
+
field :AN, :Type => AnimationStyle3D
|
286
|
+
|
287
|
+
def onInstantiate(action)
|
288
|
+
self[:OnInstantiate] = action
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
class Reference3D < Dictionary
|
293
|
+
include StandardObject
|
294
|
+
|
295
|
+
field :Type, :Type => Name, :Default => :"3DRef"
|
296
|
+
field :"3DD", :Type => U3DStream
|
297
|
+
end
|
298
|
+
|
299
|
+
class Units3D < Dictionary
|
300
|
+
include StandardObject
|
301
|
+
|
302
|
+
field :TSm, :Type => Number, :Default => 1.0
|
303
|
+
field :TSn, :Type => Number, :Default => 1.0
|
304
|
+
field :TU, :Type => String
|
305
|
+
field :USm, :Type => Number, :Default => 1.0
|
306
|
+
field :USn, :Type => Number, :Default => 1.0
|
307
|
+
field :UU, :Type => String
|
308
|
+
field :DSm, :Type => Number, :Default => 1.0
|
309
|
+
field :DSn, :Type => Number, :Default => 1.0
|
310
|
+
field :DU, :Type => String
|
311
|
+
end
|
312
|
+
|
313
|
+
class Annotation
|
314
|
+
|
315
|
+
#
|
316
|
+
# 3D Artwork annotation.
|
317
|
+
#
|
318
|
+
class Artwork3D < Annotation
|
319
|
+
|
320
|
+
class Activation < Dictionary
|
321
|
+
include StandardObject
|
322
|
+
|
323
|
+
module Events
|
324
|
+
PAGE_OPEN = :PO
|
325
|
+
PAGE_CLOSE = :PC
|
326
|
+
PAGE_VISIBLE = :PV
|
327
|
+
PAGE_INVISIBLE = :PI
|
328
|
+
USER_ACTIVATE = :XA
|
329
|
+
USER_DEACTIVATE = :XD
|
330
|
+
end
|
331
|
+
|
332
|
+
module State
|
333
|
+
UNINSTANCIATED = :U
|
334
|
+
INSTANCIATED = :I
|
335
|
+
LIVE = :L
|
336
|
+
end
|
337
|
+
|
338
|
+
module Style
|
339
|
+
EMBEDDED = :Embedded
|
340
|
+
WINDOWED = :Windowed
|
341
|
+
end
|
342
|
+
|
343
|
+
field :A, :Type => Name, :Default => Events::USER_ACTIVATE
|
344
|
+
field :AIS, :Type => Name, :Default => State::LIVE
|
345
|
+
field :D, :Type => Name, :Default => Events::PAGE_INVISIBLE
|
346
|
+
field :DIS, :Type => Name, :Default => State::UNINSTANCIATED
|
347
|
+
field :TB, :Type => Boolean, :Version => "1.7", :Default => true
|
348
|
+
field :NP, :Type => Boolean, :Version => "1.7", :Default => false
|
349
|
+
field :Style, :Type => Name, :Version => "1.7", :ExtensionLevel => 3, :Default => Style::EMBEDDED
|
350
|
+
field :Window, :Type => RichMedia::Window, :Version => "1.7", :ExtensionLevel => 3
|
351
|
+
field :Transparent, :Type => Boolean, :Version => "1.7", :ExtensionLevel => 3, :Default => false
|
352
|
+
end
|
353
|
+
|
354
|
+
field :Subtype, :Type => Name, :Default => :"3D", :Version => "1.6", :Required => true
|
355
|
+
field :"3DD", :Type => [ Reference3D, U3DStream ], :Required => true
|
356
|
+
field :"3DV", :Type => Object
|
357
|
+
field :"3DA", :Type => Activation
|
358
|
+
field :"3DI", :Type => Boolean, :Default => true
|
359
|
+
field :"3DB", :Type => Rectangle
|
360
|
+
field :"3DU", :Type => Units3D, :Version => "1.7", :ExtensionLevel => 3
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
end
|
@@ -0,0 +1,321 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
This file is part of Origami, PDF manipulation framework for Ruby
|
4
|
+
Copyright (C) 2016 Guillaume Delugré.
|
5
|
+
|
6
|
+
Origami is free software: you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
Origami is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU Lesser General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU Lesser General Public License
|
17
|
+
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
=end
|
20
|
+
|
21
|
+
module Origami
|
22
|
+
|
23
|
+
class PDF
|
24
|
+
|
25
|
+
#
|
26
|
+
# Returns true if the document contains an acrobat form.
|
27
|
+
#
|
28
|
+
def form?
|
29
|
+
self.Catalog.key? :AcroForm
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Creates a new AcroForm with specified fields.
|
34
|
+
#
|
35
|
+
def create_form(*fields)
|
36
|
+
acroform = self.Catalog.AcroForm ||= InteractiveForm.new.set_indirect(true)
|
37
|
+
self.add_fields(*fields)
|
38
|
+
|
39
|
+
acroform
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# Add a field to the Acrobat form.
|
44
|
+
# _field_:: The Field to add.
|
45
|
+
#
|
46
|
+
def add_fields(*fields)
|
47
|
+
raise TypeError, "Expected Field arguments" unless fields.all? { |f| f.is_a?(Field) }
|
48
|
+
|
49
|
+
self.Catalog.AcroForm ||= InteractiveForm.new.set_indirect(true)
|
50
|
+
self.Catalog.AcroForm.Fields ||= []
|
51
|
+
|
52
|
+
self.Catalog.AcroForm.Fields.concat(fields)
|
53
|
+
fields.each do |field| field.set_indirect(true) end
|
54
|
+
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Returns an Array of Acroform fields.
|
60
|
+
#
|
61
|
+
def fields
|
62
|
+
self.each_field.to_a
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# Iterates over each Acroform Field.
|
67
|
+
#
|
68
|
+
def each_field
|
69
|
+
return enum_for(__method__) do
|
70
|
+
if self.form? and self.Catalog.AcroForm.Fields.is_a?(Array)
|
71
|
+
self.Catalog.AcroForm.Fields.length
|
72
|
+
else
|
73
|
+
0
|
74
|
+
end
|
75
|
+
end unless block_given?
|
76
|
+
|
77
|
+
if self.form? and self.Catalog.AcroForm.Fields.is_a?(Array)
|
78
|
+
self.Catalog.AcroForm.Fields.each do |field|
|
79
|
+
yield(field.solve)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Returns the corresponding named Field.
|
86
|
+
#
|
87
|
+
def get_field(name)
|
88
|
+
self.each_field do |field|
|
89
|
+
return field if field[:T].solve == name
|
90
|
+
end
|
91
|
+
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Class representing a interactive form Dictionary.
|
98
|
+
#
|
99
|
+
class InteractiveForm < Dictionary
|
100
|
+
include StandardObject
|
101
|
+
|
102
|
+
#
|
103
|
+
# Flags relative to signature fields.
|
104
|
+
#
|
105
|
+
module SigFlags
|
106
|
+
SIGNATURES_EXIST = 1 << 0
|
107
|
+
APPEND_ONLY = 1 << 1
|
108
|
+
end
|
109
|
+
|
110
|
+
field :Fields, :Type => Array, :Required => true, :Default => []
|
111
|
+
field :NeedAppearances, :Type => Boolean, :Default => false
|
112
|
+
field :SigFlags, :Type => Integer, :Default => 0
|
113
|
+
field :CO, :Type => Array, :Version => "1.3"
|
114
|
+
field :DR, :Type => Dictionary
|
115
|
+
field :DA, :Type => String
|
116
|
+
field :Q, :Type => Integer
|
117
|
+
field :XFA, :Type => [ XFAStream, Array.of(String, XFAStream) ]
|
118
|
+
end
|
119
|
+
|
120
|
+
module Field
|
121
|
+
#
|
122
|
+
# Types of fields.
|
123
|
+
#
|
124
|
+
module Type
|
125
|
+
BUTTON = :Btn
|
126
|
+
TEXT = :Tx
|
127
|
+
CHOICE = :Ch
|
128
|
+
SIGNATURE = :Sig
|
129
|
+
end
|
130
|
+
|
131
|
+
#
|
132
|
+
# Flags relative to fields.
|
133
|
+
#
|
134
|
+
module Flags
|
135
|
+
READONLY = 1 << 0
|
136
|
+
REQUIRED = 1 << 1
|
137
|
+
NOEXPORT = 1 << 2
|
138
|
+
end
|
139
|
+
|
140
|
+
module TextAlign
|
141
|
+
LEFT = 0
|
142
|
+
CENTER = 1
|
143
|
+
RIGHT = 2
|
144
|
+
end
|
145
|
+
|
146
|
+
class AdditionalActions < Dictionary
|
147
|
+
include StandardObject
|
148
|
+
|
149
|
+
field :K, :Type => Dictionary, :Version => "1.3"
|
150
|
+
field :F, :Type => Dictionary, :Version => "1.3"
|
151
|
+
field :V, :Type => Dictionary, :Version => "1.3"
|
152
|
+
field :C, :Type => Dictionary, :Version => "1.3"
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.included(receiver) #:nodoc:
|
156
|
+
receiver.field :FT, :Type => Name, :Required => true
|
157
|
+
receiver.field :Parent, :Type => Field
|
158
|
+
receiver.field :Kids, :Type => Array.of(Field)
|
159
|
+
receiver.field :T, :Type => String
|
160
|
+
receiver.field :TU, :Type => String, :Version => "1.3"
|
161
|
+
receiver.field :TM, :Type => String, :Version => "1.3"
|
162
|
+
receiver.field :Ff, :Type => Integer, :Default => 0
|
163
|
+
receiver.field :V, :Type => Object
|
164
|
+
receiver.field :DV, :Type => Object
|
165
|
+
receiver.field :AA, :Type => AdditionalActions, :Version => "1.2"
|
166
|
+
|
167
|
+
# Variable text fields
|
168
|
+
receiver.field :DA, :Type => String, :Default => "/F1 10 Tf 0 g", :Required => true
|
169
|
+
receiver.field :Q, :Type => Integer, :Default => TextAlign::LEFT
|
170
|
+
receiver.field :DS, :Type => String, :Version => "1.5"
|
171
|
+
receiver.field :RV, :Type => [ String, Stream ], :Version => "1.5"
|
172
|
+
end
|
173
|
+
|
174
|
+
def pre_build #:nodoc:
|
175
|
+
unless self.key?(:T)
|
176
|
+
self.set_name "field#{self.object_id}"
|
177
|
+
end
|
178
|
+
|
179
|
+
super
|
180
|
+
end
|
181
|
+
|
182
|
+
#
|
183
|
+
# Sets the (partial) name of the field.
|
184
|
+
#
|
185
|
+
def set_name(field_name)
|
186
|
+
self.T = field_name
|
187
|
+
self
|
188
|
+
end
|
189
|
+
|
190
|
+
#
|
191
|
+
# Sets the (partial) name of the field.
|
192
|
+
#
|
193
|
+
def name=(field_name)
|
194
|
+
self.T = field_name
|
195
|
+
end
|
196
|
+
|
197
|
+
#
|
198
|
+
# Returns the (partial) name of the field.
|
199
|
+
#
|
200
|
+
def name
|
201
|
+
self.T
|
202
|
+
end
|
203
|
+
|
204
|
+
def onKeyStroke(action)
|
205
|
+
unless action.is_a?(Action)
|
206
|
+
raise TypeError, "An Action object must be passed."
|
207
|
+
end
|
208
|
+
|
209
|
+
self.AA ||= AdditionalActions.new
|
210
|
+
self.AA.K = action
|
211
|
+
end
|
212
|
+
|
213
|
+
def onFormat(action)
|
214
|
+
unless action.is_a?(Action)
|
215
|
+
raise TypeError, "An Action object must be passed."
|
216
|
+
end
|
217
|
+
|
218
|
+
self.AA ||= AdditionalActions.new
|
219
|
+
self.AA.F = action
|
220
|
+
end
|
221
|
+
|
222
|
+
def onValidate(action)
|
223
|
+
unless action.is_a?(Action)
|
224
|
+
raise TypeError, "An Action object must be passed."
|
225
|
+
end
|
226
|
+
|
227
|
+
self.AA ||= AdditionalActions.new
|
228
|
+
self.AA.V = action
|
229
|
+
end
|
230
|
+
|
231
|
+
def onCalculate(action)
|
232
|
+
unless action.is_a?(Action)
|
233
|
+
raise TypeError, "An Action object must be passed."
|
234
|
+
end
|
235
|
+
|
236
|
+
self.AA ||= AdditionalActions.new
|
237
|
+
self.AA.C = action
|
238
|
+
end
|
239
|
+
|
240
|
+
class Subform < Dictionary
|
241
|
+
include StandardObject
|
242
|
+
include Field
|
243
|
+
|
244
|
+
def add_fields(*fields)
|
245
|
+
self.Kids ||= []
|
246
|
+
self.Kids.concat(fields)
|
247
|
+
|
248
|
+
fields.each { |field| field.Parent = self }
|
249
|
+
|
250
|
+
self
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
class SignatureLock < Dictionary
|
255
|
+
include StandardObject
|
256
|
+
|
257
|
+
module Actions
|
258
|
+
ALL = :All
|
259
|
+
INCLUDE = :Include
|
260
|
+
EXCLUDE = :Exclude
|
261
|
+
end
|
262
|
+
|
263
|
+
field :Type, :Type => Name, :Default => :SigFieldLock
|
264
|
+
field :Action, :Type => Name, :Required => true
|
265
|
+
field :Fields, :Type => Array
|
266
|
+
|
267
|
+
def pre_build
|
268
|
+
if self.Action and self.Action != Actions::ALL
|
269
|
+
self.Fields ||= []
|
270
|
+
end
|
271
|
+
|
272
|
+
super
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
class SignatureSeedValue < Dictionary
|
277
|
+
include StandardObject
|
278
|
+
|
279
|
+
module Digest
|
280
|
+
SHA1 = :SHA1
|
281
|
+
SHA256 = :SHA256
|
282
|
+
SHA384 = :SHA384
|
283
|
+
SHA512 = :SHA512
|
284
|
+
RIPEMD160 = :RIPEMD160
|
285
|
+
end
|
286
|
+
|
287
|
+
field :Type, :Type => Name, :Default => :SV
|
288
|
+
field :Filter, :Type => Name
|
289
|
+
field :SubFilter, :Type => Array
|
290
|
+
field :DigestMethod, :Type => Array, :Default => Digest::SHA1, :Version => "1.7"
|
291
|
+
field :V, :Type => Real, :Default => 1.0
|
292
|
+
field :Cert, :Type => Dictionary
|
293
|
+
field :Reasons, :Type => Array
|
294
|
+
field :MDP, :Type => Dictionary, :Version => "1.6"
|
295
|
+
field :TimeStamp, :Type => Dictionary, :Version => "1.6"
|
296
|
+
field :LegalAttestation, :Type => Array, :Version => "1.6"
|
297
|
+
field :AddRevInfo, :Type => Boolean, :Default => false, :Version => "1.7"
|
298
|
+
field :Ff, :Type => Integer, :Default => 0
|
299
|
+
end
|
300
|
+
|
301
|
+
class CertificateSeedValue < Dictionary
|
302
|
+
include StandardObject
|
303
|
+
|
304
|
+
module URL
|
305
|
+
BROWSER = :Browser
|
306
|
+
ASSP = :ASSP
|
307
|
+
end
|
308
|
+
|
309
|
+
field :Type, :Type => Name, :Default => :SVCert
|
310
|
+
field :Subject, :Type => Array
|
311
|
+
field :SubjectDN, :Type => Array, :Version => "1.7"
|
312
|
+
field :KeyUsage, :Type => Array, :Version => "1.7"
|
313
|
+
field :Issuer, :Type => Array
|
314
|
+
field :OID, :Type => Array
|
315
|
+
field :URL, :Type => String
|
316
|
+
field :URLType, :Type => Name, :Default => URL::BROWSER, :Version => "1.7"
|
317
|
+
field :Ff, :Type => Integer, :Default => 0
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|