origami 1.0.2
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.
- data/COPYING.LESSER +165 -0
- data/README +77 -0
- data/VERSION +1 -0
- data/bin/config/pdfcop.conf.yml +237 -0
- data/bin/gui/about.rb +46 -0
- data/bin/gui/config.rb +132 -0
- data/bin/gui/file.rb +385 -0
- data/bin/gui/hexdump.rb +74 -0
- data/bin/gui/hexview.rb +91 -0
- data/bin/gui/imgview.rb +72 -0
- data/bin/gui/menu.rb +392 -0
- data/bin/gui/properties.rb +132 -0
- data/bin/gui/signing.rb +635 -0
- data/bin/gui/textview.rb +107 -0
- data/bin/gui/treeview.rb +409 -0
- data/bin/gui/walker.rb +282 -0
- data/bin/gui/xrefs.rb +79 -0
- data/bin/pdf2graph +121 -0
- data/bin/pdf2ruby +353 -0
- data/bin/pdfcocoon +104 -0
- data/bin/pdfcop +455 -0
- data/bin/pdfdecompress +104 -0
- data/bin/pdfdecrypt +95 -0
- data/bin/pdfencrypt +112 -0
- data/bin/pdfextract +221 -0
- data/bin/pdfmetadata +123 -0
- data/bin/pdfsh +13 -0
- data/bin/pdfwalker +7 -0
- data/bin/shell/.irbrc +104 -0
- data/bin/shell/console.rb +136 -0
- data/bin/shell/hexdump.rb +83 -0
- data/origami.rb +36 -0
- data/origami/3d.rb +239 -0
- data/origami/acroform.rb +321 -0
- data/origami/actions.rb +299 -0
- data/origami/adobe/fdf.rb +259 -0
- data/origami/adobe/ppklite.rb +489 -0
- data/origami/annotations.rb +775 -0
- data/origami/array.rb +187 -0
- data/origami/boolean.rb +101 -0
- data/origami/catalog.rb +486 -0
- data/origami/destinations.rb +213 -0
- data/origami/dictionary.rb +188 -0
- data/origami/docmdp.rb +96 -0
- data/origami/encryption.rb +1293 -0
- data/origami/export.rb +283 -0
- data/origami/file.rb +222 -0
- data/origami/filters.rb +250 -0
- data/origami/filters/ascii.rb +189 -0
- data/origami/filters/ccitt.rb +515 -0
- data/origami/filters/crypt.rb +47 -0
- data/origami/filters/dct.rb +61 -0
- data/origami/filters/flate.rb +112 -0
- data/origami/filters/jbig2.rb +63 -0
- data/origami/filters/jpx.rb +53 -0
- data/origami/filters/lzw.rb +195 -0
- data/origami/filters/predictors.rb +276 -0
- data/origami/filters/runlength.rb +117 -0
- data/origami/font.rb +209 -0
- data/origami/functions.rb +93 -0
- data/origami/graphics.rb +33 -0
- data/origami/graphics/colors.rb +191 -0
- data/origami/graphics/instruction.rb +126 -0
- data/origami/graphics/path.rb +154 -0
- data/origami/graphics/patterns.rb +180 -0
- data/origami/graphics/state.rb +164 -0
- data/origami/graphics/text.rb +224 -0
- data/origami/graphics/xobject.rb +493 -0
- data/origami/header.rb +90 -0
- data/origami/linearization.rb +318 -0
- data/origami/metadata.rb +114 -0
- data/origami/name.rb +170 -0
- data/origami/null.rb +75 -0
- data/origami/numeric.rb +188 -0
- data/origami/obfuscation.rb +233 -0
- data/origami/object.rb +527 -0
- data/origami/outline.rb +59 -0
- data/origami/page.rb +559 -0
- data/origami/parser.rb +268 -0
- data/origami/parsers/fdf.rb +45 -0
- data/origami/parsers/pdf.rb +27 -0
- data/origami/parsers/pdf/linear.rb +113 -0
- data/origami/parsers/ppklite.rb +86 -0
- data/origami/pdf.rb +1144 -0
- data/origami/reference.rb +113 -0
- data/origami/signature.rb +474 -0
- data/origami/stream.rb +575 -0
- data/origami/string.rb +416 -0
- data/origami/trailer.rb +173 -0
- data/origami/webcapture.rb +87 -0
- data/origami/xfa.rb +3027 -0
- data/origami/xreftable.rb +447 -0
- data/templates/patterns.rb +66 -0
- data/templates/widgets.rb +173 -0
- data/templates/xdp.rb +92 -0
- data/tests/dataset/test.dummycrt +28 -0
- data/tests/dataset/test.dummykey +27 -0
- data/tests/tc_actions.rb +32 -0
- data/tests/tc_annotations.rb +85 -0
- data/tests/tc_pages.rb +37 -0
- data/tests/tc_pdfattach.rb +24 -0
- data/tests/tc_pdfencrypt.rb +110 -0
- data/tests/tc_pdfnew.rb +32 -0
- data/tests/tc_pdfparse.rb +98 -0
- data/tests/tc_pdfsig.rb +37 -0
- data/tests/tc_streams.rb +129 -0
- data/tests/ts_pdf.rb +45 -0
- metadata +193 -0
data/origami.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
= File
|
4
|
+
origami.rb
|
5
|
+
|
6
|
+
= Info
|
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
|
+
=end
|
21
|
+
|
22
|
+
|
23
|
+
if RUBY_VERSION < '1.9'
|
24
|
+
class Fixnum
|
25
|
+
def ord; self; end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Hash
|
29
|
+
alias key index
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'origami/parsers/pdf'
|
34
|
+
require 'origami/parsers/fdf'
|
35
|
+
require 'origami/parsers/ppklite'
|
36
|
+
|
data/origami/3d.rb
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
= File
|
4
|
+
3d.rb
|
5
|
+
|
6
|
+
= Info
|
7
|
+
This file is part of Origami, PDF manipulation framework for Ruby
|
8
|
+
Copyright (C) 2010 Guillaume Delugr� <guillaume@security-labs.org>
|
9
|
+
All right reserved.
|
10
|
+
|
11
|
+
Origami is free software: you can redistribute it and/or modify
|
12
|
+
it under the terms of the GNU Lesser General Public License as published by
|
13
|
+
the Free Software Foundation, either version 3 of the License, or
|
14
|
+
(at your option) any later version.
|
15
|
+
|
16
|
+
Origami is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
GNU Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public License
|
22
|
+
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
23
|
+
|
24
|
+
=end
|
25
|
+
|
26
|
+
module Origami
|
27
|
+
|
28
|
+
class Annotation
|
29
|
+
|
30
|
+
#
|
31
|
+
# 3D Artwork annotation.
|
32
|
+
#
|
33
|
+
class Artwork3D < Annotation
|
34
|
+
field :Subtype, :Type => Name, :Default => :"3D", :Version => "1.6", :Required => true
|
35
|
+
field :"3DD", :Type => [ Dictionary, Stream ], :Required => true
|
36
|
+
field :"3DV", :Type => Object
|
37
|
+
field :"3DA", :Type => Dictionary
|
38
|
+
field :"3DI", :Type => Boolean, :Default => true
|
39
|
+
field :"3DB", :Type => Array
|
40
|
+
|
41
|
+
class Activation < Dictionary
|
42
|
+
include StandardObject
|
43
|
+
|
44
|
+
module Events
|
45
|
+
PAGE_OPEN = :PO
|
46
|
+
PAGE_CLOSE = :PC
|
47
|
+
PAGE_VISIBLE = :PV
|
48
|
+
PAGE_INVISIBLE = :PI
|
49
|
+
USER_ACTIVATE = :XA
|
50
|
+
USER_DEACTIVATE = :XD
|
51
|
+
end
|
52
|
+
|
53
|
+
module State
|
54
|
+
UNINSTANCIATED = :U
|
55
|
+
INSTANCIATED = :I
|
56
|
+
LIVE = :L
|
57
|
+
end
|
58
|
+
|
59
|
+
field :A, :Type => Name, :Default => Events::USER_ACTIVATE
|
60
|
+
field :AIS, :Type => Name, :Default => State::LIVE
|
61
|
+
field :D, :Type => Name, :Default => Events::PAGE_INVISIBLE
|
62
|
+
field :DIS, :Type => Name, :Default => State::UNINSTANCIATED
|
63
|
+
field :TB, :Type => Boolean, :Version => "1.7", :Default => true
|
64
|
+
field :NP, :Type => Boolean, :Version => "1.7", :Default => false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
class U3DStream < Stream
|
71
|
+
include StandardObject
|
72
|
+
|
73
|
+
field :Type, :Type => Name, :Default => :"3D"
|
74
|
+
field :Subtype, :Type => Name, :Default => :U3D, :Required => true
|
75
|
+
field :VA, :Type => Dictionary
|
76
|
+
field :DV, :Type => Object
|
77
|
+
field :Resources, :Type => Dictionary
|
78
|
+
field :OnInstantiate, :Type => Stream
|
79
|
+
field :AN, :Type => Dictionary
|
80
|
+
|
81
|
+
def onInstantiate(action)
|
82
|
+
self[:OnInstantiate] = action
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class AnimationStyle3D < Dictionary
|
87
|
+
include StandardObject
|
88
|
+
|
89
|
+
module Styles
|
90
|
+
NONE = :None
|
91
|
+
LINEAR = :Linear
|
92
|
+
OSCILLATING = :Oscillating
|
93
|
+
end
|
94
|
+
|
95
|
+
field :Type, :Type => Name, :Default => "3DAnimationStyle"
|
96
|
+
field :Subtype, :Type => Name, :Default => Styles::NONE
|
97
|
+
field :PC, :Type => Integer, :Default => 0
|
98
|
+
field :TM, :Type => Number, :Default => 1
|
99
|
+
end
|
100
|
+
|
101
|
+
class Reference3D < Dictionary
|
102
|
+
include StandardObject
|
103
|
+
|
104
|
+
field :Type, :Type => Name, :Default => :"3DRef"
|
105
|
+
field :"3DD", :Type => Stream
|
106
|
+
end
|
107
|
+
|
108
|
+
class View3D < Dictionary
|
109
|
+
include StandardObject
|
110
|
+
|
111
|
+
field :Type, :Type => Name, :Default => :"3DView"
|
112
|
+
field :XN, :Type => ByteString, :Required => true
|
113
|
+
field :IN, :Type => ByteString
|
114
|
+
field :MS, :Type => Name
|
115
|
+
field :C2W, :Type => Array
|
116
|
+
field :U3DPath, :Type => [ ByteString, Array ]
|
117
|
+
field :CO, :Type => Number
|
118
|
+
field :P, :Type => Dictionary
|
119
|
+
field :O, :Type => Stream
|
120
|
+
field :BG, :Type => Dictionary
|
121
|
+
field :RM, :Type => Dictionary, :Version => "1.7"
|
122
|
+
field :LS, :Type => Dictionary, :Version => "1.7"
|
123
|
+
field :SA, :Type => Array, :Version => "1.7"
|
124
|
+
field :NA, :Type => Array, :Version => "1.7"
|
125
|
+
field :NR, :Type => Boolean, :Version => "1.7", :Default => false
|
126
|
+
end
|
127
|
+
|
128
|
+
class Projection3D < Dictionary
|
129
|
+
include StandardObject
|
130
|
+
|
131
|
+
ORTHOGRAPHIC = :O
|
132
|
+
PERSPECTIVE = :P
|
133
|
+
|
134
|
+
module ClippingStyles
|
135
|
+
EXPLICIT_NEARFAR = :XNF
|
136
|
+
AUTOMATIC_NEARFAR = :ANF
|
137
|
+
end
|
138
|
+
|
139
|
+
module Scaling
|
140
|
+
WIDTH = :W
|
141
|
+
HEIGHT = :H
|
142
|
+
MINIMUM = :Min
|
143
|
+
MAXIMUM = :Max
|
144
|
+
ABSOLUTE = :Absolute
|
145
|
+
end
|
146
|
+
|
147
|
+
field :Subtype, :Type => Name, :Default => ORTHOGRAPHIC
|
148
|
+
field :CS, :Type => Name, :Default => ClippingStyles::AUTOMATIC_NEARFAR
|
149
|
+
field :F, :Type => Number
|
150
|
+
field :N, :Type => Number
|
151
|
+
field :FOV, :Type => Number
|
152
|
+
field :PS, :Type => [ Number, Name ], :Default => Scaling::WIDTH
|
153
|
+
field :OS, :Type => Number, :Default => 1
|
154
|
+
field :OB, :Type => Name, :Version => "1.7", :Default => Scaling::ABSOLUTE
|
155
|
+
end
|
156
|
+
|
157
|
+
class Background3D < Dictionary
|
158
|
+
include StandardObject
|
159
|
+
|
160
|
+
field :Type, :Type => Name, :Default => :"3DBG"
|
161
|
+
field :Subtype, :Type => Name, :Default => :SC
|
162
|
+
field :CS, :Type => [ Name, Array ], :Default => Graphics::Color::Space::DEVICE_RGB
|
163
|
+
field :C, :Type => Object, :Default => [ 1, 1, 1 ]
|
164
|
+
field :EA, :Type => Boolean, :Default => false
|
165
|
+
end
|
166
|
+
|
167
|
+
class RenderMode3D < Dictionary
|
168
|
+
include StandardObject
|
169
|
+
|
170
|
+
module Modes
|
171
|
+
SOLID = :Solid
|
172
|
+
SOLID_WIREFRAME = :SolidWireFrame
|
173
|
+
TRANSPARENT = :Transparent
|
174
|
+
TRANSPARENT_WIREFRAME = :TransparentWireFrame
|
175
|
+
BOUNDINGBOX = :BoundingBox
|
176
|
+
TRANSPARENT_BOUNDINGBOX = :TransparentBoundingBox
|
177
|
+
TRANSPARENT_BOUNDINGBOX_OUTLINE = :TransparentBoundingBoxOutline
|
178
|
+
WIREFRAME = :WireFrame
|
179
|
+
SHADED_WIREFRAME = :ShadedWireFrame
|
180
|
+
HIDDEN_WIREFRAME = :HiddenWireFrame
|
181
|
+
VERTICES = :Vertices
|
182
|
+
SHADED_VERTICES = :ShadedVertices
|
183
|
+
ILLUSTRATION = :Illustration
|
184
|
+
SOLID_OUTLINE = :SolidOutline
|
185
|
+
SHADED_ILLUSTRATION = :ShadedIllustration
|
186
|
+
end
|
187
|
+
|
188
|
+
field :Type, :Type => Name, :Default => :"3DRenderMode"
|
189
|
+
field :Subtype, :Type => Name, :Required => true, :Version => "1.7"
|
190
|
+
field :AC, :Type => Array, :Default => [ Graphics::Color::Space::DEVICE_RGB, 0, 0, 0]
|
191
|
+
field :BG, :Type => [ Name, Array ], :Default => :BG
|
192
|
+
field :O, :Type => Number, :Default => 0.5
|
193
|
+
field :CV, :Type => Number, :Default => 45
|
194
|
+
end
|
195
|
+
|
196
|
+
class LightingScheme3D < Dictionary
|
197
|
+
include StandardObject
|
198
|
+
|
199
|
+
module Styles
|
200
|
+
ARTWORK = :Artwork
|
201
|
+
NONE = :None
|
202
|
+
WHITE = :White
|
203
|
+
DAY = :Day
|
204
|
+
NIGHT = :Night
|
205
|
+
HARD = :Hard
|
206
|
+
PRIMARY = :Primary
|
207
|
+
BLUE = :Blue
|
208
|
+
RED = :Red
|
209
|
+
CUBE = :Cube
|
210
|
+
CAD = :CAD
|
211
|
+
HEADLAMP = :HeadLamp
|
212
|
+
end
|
213
|
+
|
214
|
+
field :Type, :Type => Name, :Default => :"3DLightingScheme"
|
215
|
+
field :Subtype, :Type => Name, :Version => "1.7", :Required => true
|
216
|
+
end
|
217
|
+
|
218
|
+
class CrossSection3D < Dictionary
|
219
|
+
include StandardObject
|
220
|
+
|
221
|
+
field :Type, :Type => Name, :Default => :"3DCrossSection"
|
222
|
+
field :C, :Type => Array, :Default => [ 0, 0, 0 ]
|
223
|
+
field :O, :Type => Array, :Version => "1.7", :Default => [ Null.new, 0, 0 ], :Required => true
|
224
|
+
field :PO, :Type => Number, :Default => 0.5
|
225
|
+
field :PC, :Type => Array, :Default => [ Graphics::Color::Space::DEVICE_RGB, 1, 1, 1 ]
|
226
|
+
field :IV, :Type => Boolean, :Default => false
|
227
|
+
field :IC, :Type => Array, :Default => [ Graphics::Color::Space::DEVICE_RGB, 0, 1 ,0]
|
228
|
+
end
|
229
|
+
|
230
|
+
class Node3D < Dictionary
|
231
|
+
include StandardObject
|
232
|
+
|
233
|
+
field :Type, :Type => Name, :Default => :"3DNode"
|
234
|
+
field :N, :Type => ByteString, :Version => "1.7", :Required => true
|
235
|
+
field :O, :Type => Number
|
236
|
+
field :V, :Type => Boolean
|
237
|
+
field :M, :Type => Array
|
238
|
+
end
|
239
|
+
end
|
data/origami/acroform.rb
ADDED
@@ -0,0 +1,321 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
= File
|
4
|
+
acroform.rb
|
5
|
+
|
6
|
+
= Info
|
7
|
+
This file is part of Origami, PDF manipulation framework for Ruby
|
8
|
+
Copyright (C) 2010 Guillaume Delugr� <guillaume@security-labs.org>
|
9
|
+
All right reserved.
|
10
|
+
|
11
|
+
Origami is free software: you can redistribute it and/or modify
|
12
|
+
it under the terms of the GNU Lesser General Public License as published by
|
13
|
+
the Free Software Foundation, either version 3 of the License, or
|
14
|
+
(at your option) any later version.
|
15
|
+
|
16
|
+
Origami is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
+
GNU Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public License
|
22
|
+
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
23
|
+
|
24
|
+
=end
|
25
|
+
|
26
|
+
module Origami
|
27
|
+
|
28
|
+
class PDF
|
29
|
+
|
30
|
+
#
|
31
|
+
# Returns true if the document contains an acrobat form.
|
32
|
+
#
|
33
|
+
def has_form?
|
34
|
+
(not self.Catalog.nil?) and self.Catalog.has_key? :AcroForm
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Creates a new AcroForm with specified fields.
|
39
|
+
#
|
40
|
+
def create_acroform(*fields)
|
41
|
+
acroform = self.Catalog.AcroForm ||= InteractiveForm.new.set_indirect(true)
|
42
|
+
self.add_fields(*fields)
|
43
|
+
|
44
|
+
acroform
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Add a field to the Acrobat form.
|
49
|
+
# _field_:: The Field to add.
|
50
|
+
#
|
51
|
+
def add_fields(*fields)
|
52
|
+
raise TypeError, "Expected Field arguments" unless fields.all? { |f| f.is_a?(Field) }
|
53
|
+
|
54
|
+
self.Catalog.AcroForm ||= InteractiveForm.new.set_indirect(true)
|
55
|
+
self.Catalog.AcroForm.Fields ||= []
|
56
|
+
|
57
|
+
self.Catalog.AcroForm.Fields.concat(fields)
|
58
|
+
fields.each do |field| field.set_indirect(true) end
|
59
|
+
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Returns an array of Acroform fields.
|
65
|
+
#
|
66
|
+
def fields
|
67
|
+
if self.has_form?
|
68
|
+
if self.Catalog.AcroForm.has_key?(:Fields)
|
69
|
+
self.Catalog.AcroForm[:Fields].map {|field| field.solve}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Iterates over each Acroform Field.
|
76
|
+
#
|
77
|
+
def each_field(&b)
|
78
|
+
if self.has_form?
|
79
|
+
if self.Catalog.AcroForm.has_key?(:Fields)
|
80
|
+
self.Catalog.AcroForm[:Fields].each {|field| b.call(field.solve)}
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
#
|
86
|
+
# Returns the corresponding named Field.
|
87
|
+
#
|
88
|
+
def get_field(name)
|
89
|
+
self.each_field do |field|
|
90
|
+
return field if field[:T].solve == name
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# Class representing a interactive form Dictionary.
|
97
|
+
#
|
98
|
+
class InteractiveForm < Dictionary
|
99
|
+
|
100
|
+
include StandardObject
|
101
|
+
|
102
|
+
#
|
103
|
+
# Flags relative to signature fields.
|
104
|
+
#
|
105
|
+
module SigFlags
|
106
|
+
SIGNATURESEXIST = 1 << 0
|
107
|
+
APPENDONLY = 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 => [ Stream, Array ]
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
module Field
|
122
|
+
|
123
|
+
#
|
124
|
+
# Types of fields.
|
125
|
+
#
|
126
|
+
module Type
|
127
|
+
BUTTON = :Btn
|
128
|
+
TEXT = :Tx
|
129
|
+
CHOICE = :Ch
|
130
|
+
SIGNATURE = :Sig
|
131
|
+
end
|
132
|
+
|
133
|
+
#
|
134
|
+
# Flags relative to fields.
|
135
|
+
#
|
136
|
+
module Flags
|
137
|
+
READONLY = 1 << 0
|
138
|
+
REQUIRED = 1 << 1
|
139
|
+
NOEXPORT = 1 << 2
|
140
|
+
end
|
141
|
+
|
142
|
+
module TextAlign
|
143
|
+
LEFT = 0
|
144
|
+
CENTER = 1
|
145
|
+
RIGHT = 2
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.included(receiver)
|
149
|
+
|
150
|
+
receiver.field :FT, :Type => Name, :Default => Type::TEXT, :Required => true
|
151
|
+
receiver.field :Parent, :Type => Dictionary
|
152
|
+
receiver.field :Kids, :Type => Array
|
153
|
+
receiver.field :T, :Type => String
|
154
|
+
receiver.field :TU, :Type => String, :Version => "1.3"
|
155
|
+
receiver.field :TM, :Type => String, :Version => "1.3"
|
156
|
+
receiver.field :Ff, :Type => Integer, :Default => 0
|
157
|
+
receiver.field :V, :Type => Object
|
158
|
+
receiver.field :DV, :Type => Object
|
159
|
+
receiver.field :AA, :Type => Dictionary, :Version => "1.2"
|
160
|
+
|
161
|
+
# Variable text fields
|
162
|
+
receiver.field :DA, :Type => String, :Default => "/F1 10 Tf 0 g", :Required => true
|
163
|
+
receiver.field :Q, :Type => Integer, :Default => TextAlign::LEFT
|
164
|
+
receiver.field :DS, :Type => ByteString, :Version => "1.5"
|
165
|
+
receiver.field :RV, :Type => [ String, Stream ], :Version => "1.5"
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
def pre_build
|
170
|
+
|
171
|
+
if not self.T
|
172
|
+
self.T = "undef#{::Array.new(5) {(0x30 + rand(10)).chr}.join}"
|
173
|
+
end
|
174
|
+
|
175
|
+
super
|
176
|
+
end
|
177
|
+
|
178
|
+
def onKeyStroke(action)
|
179
|
+
|
180
|
+
unless action.is_a?(Action)
|
181
|
+
raise TypeError, "An Action object must be passed."
|
182
|
+
end
|
183
|
+
|
184
|
+
self.AA ||= AdditionalActions.new
|
185
|
+
self.AA.K = action
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
def onFormat(action)
|
190
|
+
|
191
|
+
unless action.is_a?(Action)
|
192
|
+
raise TypeError, "An Action object must be passed."
|
193
|
+
end
|
194
|
+
|
195
|
+
self.AA ||= AdditionalActions.new
|
196
|
+
self.AA.F = action
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
def onValidate(action)
|
201
|
+
|
202
|
+
unless action.is_a?(Action)
|
203
|
+
raise TypeError, "An Action object must be passed."
|
204
|
+
end
|
205
|
+
|
206
|
+
self.AA ||= AdditionalActions.new
|
207
|
+
self.AA.V = action
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
def onCalculate(action)
|
212
|
+
|
213
|
+
unless action.is_a?(Action)
|
214
|
+
raise TypeError, "An Action object must be passed."
|
215
|
+
end
|
216
|
+
|
217
|
+
self.AA ||= AdditionalActions.new
|
218
|
+
self.AA.C = action
|
219
|
+
|
220
|
+
end
|
221
|
+
|
222
|
+
class Subform < Dictionary
|
223
|
+
include StandardObject
|
224
|
+
include Field
|
225
|
+
|
226
|
+
def add_fields(*fields)
|
227
|
+
self.Kids ||= []
|
228
|
+
self.Kids.concat(fields)
|
229
|
+
|
230
|
+
fields.each do |field| field.Parent = self end
|
231
|
+
|
232
|
+
self
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
class AdditionalActions < Dictionary
|
237
|
+
|
238
|
+
include StandardObject
|
239
|
+
|
240
|
+
field :K, :Type => Dictionary, :Version => "1.3"
|
241
|
+
field :F, :Type => Dictionary, :Version => "1.3"
|
242
|
+
field :V, :Type => Dictionary, :Version => "1.3"
|
243
|
+
field :C, :Type => Dictionary, :Version => "1.3"
|
244
|
+
end
|
245
|
+
|
246
|
+
class SignatureLock < Dictionary
|
247
|
+
|
248
|
+
include StandardObject
|
249
|
+
|
250
|
+
module Actions
|
251
|
+
ALL = :All
|
252
|
+
INCLUDE = :Include
|
253
|
+
EXCLUDE = :Exclude
|
254
|
+
end
|
255
|
+
|
256
|
+
field :Type, :Type => Name, :Default => :SigFieldLock
|
257
|
+
field :Action, :Type => Name, :Default => Actions::ALL, :Required => true
|
258
|
+
field :Fields, :Type => Array
|
259
|
+
|
260
|
+
def pre_build
|
261
|
+
|
262
|
+
if self.Action and self.Action != Actions::ALL
|
263
|
+
self.Fields ||= []
|
264
|
+
end
|
265
|
+
|
266
|
+
super
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
270
|
+
|
271
|
+
class SignatureSeedValue < Dictionary
|
272
|
+
|
273
|
+
include StandardObject
|
274
|
+
|
275
|
+
module Digest
|
276
|
+
SHA1 = :SHA1
|
277
|
+
SHA256 = :SHA256
|
278
|
+
SHA384 = :SHA384
|
279
|
+
SHA512 = :SHA512
|
280
|
+
RIPEMD160 = :RIPEMD160
|
281
|
+
end
|
282
|
+
|
283
|
+
field :Type, :Type => Name, :Default => :SV
|
284
|
+
field :Filter, :Type => Name
|
285
|
+
field :SubFilter, :Type => Array
|
286
|
+
field :DigestMethod, :Type => Array, :Default => Digest::SHA1, :Version => "1.7"
|
287
|
+
field :V, :Type => Real, :Default => 1.0
|
288
|
+
field :Cert, :Type => Dictionary
|
289
|
+
field :Reasons, :Type => Array
|
290
|
+
field :MDP, :Type => Dictionary, :Version => "1.6"
|
291
|
+
field :TimeStamp, :Type => Dictionary, :Version => "1.6"
|
292
|
+
field :LegalAttestation, :Type => Array, :Version => "1.6"
|
293
|
+
field :AddRevInfo, :Type => Boolean, :Default => false, :Version => "1.7"
|
294
|
+
field :Ff, :Type => Integer, :Default => 0
|
295
|
+
|
296
|
+
end
|
297
|
+
|
298
|
+
class CertificateSeedValue < Dictionary
|
299
|
+
|
300
|
+
include StandardObject
|
301
|
+
|
302
|
+
module URL
|
303
|
+
BROWSER = :Browser
|
304
|
+
ASSP = :ASSP
|
305
|
+
end
|
306
|
+
|
307
|
+
field :Type, :Type => Name, :Default => :SVCert
|
308
|
+
field :Subject, :Type => Array
|
309
|
+
field :SubjectDN, :Type => Array, :Version => "1.7"
|
310
|
+
field :KeyUsage, :Type => Array, :Version => "1.7"
|
311
|
+
field :Issuer, :Type => Array
|
312
|
+
field :OID, :Type => Array
|
313
|
+
field :URL, :Type => ByteString
|
314
|
+
field :URLType, :Type => Name, :Default => URL::BROWSER, :Version => "1.7"
|
315
|
+
field :Ff, :Type => Integer, :Default => 0
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|