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/destinations.rb
CHANGED
@@ -1,252 +1,241 @@
|
|
1
|
-
|
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
|
+
#
|
2
20
|
|
3
|
-
|
4
|
-
|
21
|
+
module Origami
|
22
|
+
class PDF
|
23
|
+
#
|
24
|
+
# Lookup destination in the destination name directory.
|
25
|
+
#
|
26
|
+
def get_destination_by_name(name)
|
27
|
+
resolve_name Names::DESTINATIONS, name
|
28
|
+
end
|
5
29
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
(
|
30
|
+
#
|
31
|
+
# Calls block for each named destination.
|
32
|
+
#
|
33
|
+
def each_named_dest(&b)
|
34
|
+
each_name(Names::DESTINATIONS, &b)
|
35
|
+
end
|
36
|
+
end
|
10
37
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
38
|
+
#
|
39
|
+
# A destination represents a specified location into the document.
|
40
|
+
#
|
41
|
+
class Destination < Origami::Array
|
42
|
+
attr_reader :page, :top, :left, :right, :bottom, :zoom
|
15
43
|
|
16
|
-
|
17
|
-
|
44
|
+
#
|
45
|
+
# Class representing a Destination zooming on a part of a document.
|
46
|
+
#
|
47
|
+
class Zoom < Destination
|
48
|
+
def initialize(array)
|
49
|
+
super
|
50
|
+
|
51
|
+
@page, _, @left, @top, @zoom = array
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Creates a new zoom Destination.
|
56
|
+
# _page_:: The destination Page.
|
57
|
+
# _left_, _top_:: Coords in the Page.
|
58
|
+
# _zoom_:: Zoom factor.
|
59
|
+
#
|
60
|
+
def self.[](page, left: 0, top: 0, zoom: 0)
|
61
|
+
new([page, :XYZ, left, top, zoom])
|
62
|
+
end
|
63
|
+
end
|
18
64
|
|
19
|
-
|
65
|
+
def self.Zoom(page, left: 0, top: 0, zoom: 0)
|
66
|
+
Zoom[page, left: left, top: top, zoom: zoom]
|
67
|
+
end
|
20
68
|
|
21
|
-
|
69
|
+
#
|
70
|
+
# Class representing a Destination showing a Page globally.
|
71
|
+
#
|
72
|
+
class GlobalFit < Destination
|
73
|
+
def initialize(array)
|
74
|
+
super
|
75
|
+
|
76
|
+
@page, _ = array
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# Creates a new global fit Destination.
|
81
|
+
# _page_:: The destination Page.
|
82
|
+
#
|
83
|
+
def self.[](page)
|
84
|
+
new([page, :Fit])
|
85
|
+
end
|
86
|
+
end
|
22
87
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
#
|
27
|
-
def get_destination_by_name(name)
|
28
|
-
resolve_name Names::DESTINATIONS, name
|
29
|
-
end
|
30
|
-
|
31
|
-
#
|
32
|
-
# Calls block for each named destination.
|
33
|
-
#
|
34
|
-
def each_named_dest(&b)
|
35
|
-
each_name(Names::DESTINATIONS, &b)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
# A destination represents a specified location into the document.
|
41
|
-
#
|
42
|
-
class Destination < Origami::Array
|
43
|
-
attr_reader :page, :top, :left, :right, :bottom, :zoom
|
44
|
-
|
45
|
-
#
|
46
|
-
# Class representing a Destination zooming on a part of a document.
|
47
|
-
#
|
48
|
-
class Zoom < Destination
|
49
|
-
|
50
|
-
def initialize(array)
|
51
|
-
super(array)
|
52
|
-
|
53
|
-
@page, _, @left, @top, @zoom = array
|
54
|
-
end
|
55
|
-
|
56
|
-
#
|
57
|
-
# Creates a new zoom Destination.
|
58
|
-
# _page_:: The destination Page.
|
59
|
-
# _left_, _top_:: Coords in the Page.
|
60
|
-
# _zoom_:: Zoom factor.
|
61
|
-
#
|
62
|
-
def self.[](page, left: 0, top: 0, zoom: 0)
|
63
|
-
self.new([page, :XYZ, left, top, zoom])
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.Zoom(page, left: 0, top: 0, zoom: 0)
|
68
|
-
Zoom[page, left: left, top: top, zoom: zoom]
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
#
|
73
|
-
# Class representing a Destination showing a Page globally.
|
74
|
-
#
|
75
|
-
class GlobalFit < Destination
|
76
|
-
|
77
|
-
def initialize(array)
|
78
|
-
super(array)
|
79
|
-
|
80
|
-
@page, _ = array
|
81
|
-
end
|
82
|
-
|
83
|
-
#
|
84
|
-
# Creates a new global fit Destination.
|
85
|
-
# _page_:: The destination Page.
|
86
|
-
#
|
87
|
-
def self.[](page)
|
88
|
-
self.new([page, :Fit])
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def self.GlobalFit(page)
|
93
|
-
GlobalFit[page]
|
94
|
-
end
|
95
|
-
|
96
|
-
#
|
97
|
-
# Class representing a Destination fitting a Page horizontally.
|
98
|
-
#
|
99
|
-
class HorizontalFit < Destination
|
100
|
-
|
101
|
-
def initialize(array)
|
102
|
-
super(array)
|
103
|
-
|
104
|
-
@page, _, @top = array
|
105
|
-
end
|
106
|
-
|
107
|
-
#
|
108
|
-
# Creates a new horizontal fit destination.
|
109
|
-
# _page_:: The destination Page.
|
110
|
-
# _top_:: The vertical coord in the Page.
|
111
|
-
#
|
112
|
-
def self.[](page, top: 0)
|
113
|
-
self.new([page, :FitH, top])
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def self.HorizontalFit(page, top: 0)
|
118
|
-
HorizontalFit[page, top: top]
|
119
|
-
end
|
120
|
-
|
121
|
-
#
|
122
|
-
# Class representing a Destination fitting a Page vertically.
|
123
|
-
# _page_:: The destination Page.
|
124
|
-
# _left_:: The horizontal coord in the Page.
|
125
|
-
#
|
126
|
-
class VerticalFit < Destination
|
127
|
-
|
128
|
-
def initialize(array)
|
129
|
-
super(array)
|
130
|
-
|
131
|
-
@page, _, @left = array
|
132
|
-
end
|
133
|
-
|
134
|
-
def self.[](page, left: 0)
|
135
|
-
self.new([page, :FitV, left])
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def self.VerticalFit(page, left: 0)
|
140
|
-
VerticalFit[page, left: left]
|
141
|
-
end
|
142
|
-
|
143
|
-
#
|
144
|
-
# Class representing a Destination fitting the view on a rectangle in a Page.
|
145
|
-
#
|
146
|
-
class RectangleFit < Destination
|
147
|
-
|
148
|
-
def initialize(array)
|
149
|
-
super(array)
|
150
|
-
|
151
|
-
@page, _, @left, @bottom, @right, @top = array
|
152
|
-
end
|
153
|
-
|
154
|
-
#
|
155
|
-
# Creates a new rectangle fit Destination.
|
156
|
-
# _page_:: The destination Page.
|
157
|
-
# _left_, _bottom_, _right_, _top_:: The rectangle to fit in.
|
158
|
-
#
|
159
|
-
def self.[](page, left: 0, bottom: 0, right: 0, top: 0)
|
160
|
-
self.new([page, :FitR, left, bottom, right, top])
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def self.RectangleFit(page, left: 0, bottom: 0, right: 0, top: 0)
|
165
|
-
RectangleFit[page, left: left, bottom: bottom, right: right, top: top]
|
166
|
-
end
|
167
|
-
|
168
|
-
#
|
169
|
-
# Class representing a Destination fitting the bounding box of a Page.
|
170
|
-
#
|
171
|
-
class GlobalBoundingBoxFit < Destination
|
172
|
-
|
173
|
-
def initialize(array)
|
174
|
-
super(array)
|
175
|
-
|
176
|
-
@page, _, = array
|
177
|
-
end
|
178
|
-
|
179
|
-
#
|
180
|
-
# Creates a new bounding box fit Destination.
|
181
|
-
# _page_:: The destination Page.
|
182
|
-
#
|
183
|
-
def self.[](page)
|
184
|
-
self.new([page, :FitB])
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
def self.GlobalBoundingBoxFit(page)
|
189
|
-
GlobalBoundingBoxFit[page]
|
190
|
-
end
|
191
|
-
|
192
|
-
#
|
193
|
-
# Class representing a Destination fitting horizontally the bouding box a Page.
|
194
|
-
#
|
195
|
-
class HorizontalBoudingBoxFit < Destination
|
196
|
-
|
197
|
-
def initialize(array)
|
198
|
-
super(array)
|
199
|
-
|
200
|
-
@page, _, @top = array
|
201
|
-
end
|
202
|
-
|
203
|
-
#
|
204
|
-
# Creates a new horizontal bounding box fit Destination.
|
205
|
-
# _page_:: The destination Page.
|
206
|
-
# _top_:: The vertical coord.
|
207
|
-
#
|
208
|
-
def self.[](page, top: 0)
|
209
|
-
self.new([page, :FitBH, top])
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
def self.HorizontalBoudingBoxFit(page, top: 0)
|
214
|
-
HorizontalBoudingBoxFit[page, top: top]
|
215
|
-
end
|
216
|
-
|
217
|
-
#
|
218
|
-
# Class representing a Destination fitting vertically the bounding box of a Page.
|
219
|
-
#
|
220
|
-
class VerticalBoundingBoxFit < Destination
|
221
|
-
|
222
|
-
def initialize(array)
|
223
|
-
super(array)
|
224
|
-
|
225
|
-
@page, _, @left = array
|
226
|
-
end
|
88
|
+
def self.GlobalFit(page)
|
89
|
+
GlobalFit[page]
|
90
|
+
end
|
227
91
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
92
|
+
#
|
93
|
+
# Class representing a Destination fitting a Page horizontally.
|
94
|
+
#
|
95
|
+
class HorizontalFit < Destination
|
96
|
+
def initialize(array)
|
97
|
+
super
|
98
|
+
|
99
|
+
@page, _, @top = array
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# Creates a new horizontal fit destination.
|
104
|
+
# _page_:: The destination Page.
|
105
|
+
# _top_:: The vertical coord in the Page.
|
106
|
+
#
|
107
|
+
def self.[](page, top: 0)
|
108
|
+
new([page, :FitH, top])
|
109
|
+
end
|
110
|
+
end
|
237
111
|
|
238
|
-
|
239
|
-
|
240
|
-
end
|
112
|
+
def self.HorizontalFit(page, top: 0)
|
113
|
+
HorizontalFit[page, top: top]
|
241
114
|
end
|
242
115
|
|
243
116
|
#
|
244
|
-
#
|
245
|
-
#
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
117
|
+
# Class representing a Destination fitting a Page vertically.
|
118
|
+
# _page_:: The destination Page.
|
119
|
+
# _left_:: The horizontal coord in the Page.
|
120
|
+
#
|
121
|
+
class VerticalFit < Destination
|
122
|
+
def initialize(array)
|
123
|
+
super
|
124
|
+
|
125
|
+
@page, _, @left = array
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.[](page, left: 0)
|
129
|
+
new([page, :FitV, left])
|
130
|
+
end
|
250
131
|
end
|
251
132
|
|
133
|
+
def self.VerticalFit(page, left: 0)
|
134
|
+
VerticalFit[page, left: left]
|
135
|
+
end
|
136
|
+
|
137
|
+
#
|
138
|
+
# Class representing a Destination fitting the view on a rectangle in a Page.
|
139
|
+
#
|
140
|
+
class RectangleFit < Destination
|
141
|
+
def initialize(array)
|
142
|
+
super
|
143
|
+
|
144
|
+
@page, _, @left, @bottom, @right, @top = array
|
145
|
+
end
|
146
|
+
|
147
|
+
#
|
148
|
+
# Creates a new rectangle fit Destination.
|
149
|
+
# _page_:: The destination Page.
|
150
|
+
# _left_, _bottom_, _right_, _top_:: The rectangle to fit in.
|
151
|
+
#
|
152
|
+
def self.[](page, left: 0, bottom: 0, right: 0, top: 0)
|
153
|
+
new([page, :FitR, left, bottom, right, top])
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def self.RectangleFit(page, left: 0, bottom: 0, right: 0, top: 0)
|
158
|
+
RectangleFit[page, left: left, bottom: bottom, right: right, top: top]
|
159
|
+
end
|
160
|
+
|
161
|
+
#
|
162
|
+
# Class representing a Destination fitting the bounding box of a Page.
|
163
|
+
#
|
164
|
+
class GlobalBoundingBoxFit < Destination
|
165
|
+
def initialize(array)
|
166
|
+
super
|
167
|
+
|
168
|
+
@page, _, = array
|
169
|
+
end
|
170
|
+
|
171
|
+
#
|
172
|
+
# Creates a new bounding box fit Destination.
|
173
|
+
# _page_:: The destination Page.
|
174
|
+
#
|
175
|
+
def self.[](page)
|
176
|
+
new([page, :FitB])
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.GlobalBoundingBoxFit(page)
|
181
|
+
GlobalBoundingBoxFit[page]
|
182
|
+
end
|
183
|
+
|
184
|
+
#
|
185
|
+
# Class representing a Destination fitting horizontally the bouding box a Page.
|
186
|
+
#
|
187
|
+
class HorizontalBoudingBoxFit < Destination
|
188
|
+
def initialize(array)
|
189
|
+
super
|
190
|
+
|
191
|
+
@page, _, @top = array
|
192
|
+
end
|
193
|
+
|
194
|
+
#
|
195
|
+
# Creates a new horizontal bounding box fit Destination.
|
196
|
+
# _page_:: The destination Page.
|
197
|
+
# _top_:: The vertical coord.
|
198
|
+
#
|
199
|
+
def self.[](page, top: 0)
|
200
|
+
new([page, :FitBH, top])
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def self.HorizontalBoudingBoxFit(page, top: 0)
|
205
|
+
HorizontalBoudingBoxFit[page, top: top]
|
206
|
+
end
|
207
|
+
|
208
|
+
#
|
209
|
+
# Class representing a Destination fitting vertically the bounding box of a Page.
|
210
|
+
#
|
211
|
+
class VerticalBoundingBoxFit < Destination
|
212
|
+
def initialize(array)
|
213
|
+
super
|
214
|
+
|
215
|
+
@page, _, @left = array
|
216
|
+
end
|
217
|
+
|
218
|
+
#
|
219
|
+
# Creates a new vertical bounding box fit Destination.
|
220
|
+
# _page_:: The destination Page.
|
221
|
+
# _left_:: The horizontal coord.
|
222
|
+
#
|
223
|
+
def self.[](page, left: 0)
|
224
|
+
new([page, :FitBV, left])
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def self.VerticalBoundingBoxFit(page, left: 0)
|
229
|
+
VerticalBoundingBoxFit[page, left: left]
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
#
|
234
|
+
# This kind of Dictionary is used in named destinations.
|
235
|
+
#
|
236
|
+
class DestinationDictionary < Dictionary
|
237
|
+
include StandardObject
|
238
|
+
|
239
|
+
field :D, Type: Destination, Required: true
|
240
|
+
end
|
252
241
|
end
|