pdfrb 0.7.24 → 0.7.26
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/lib/pdfrb/model/cos/arlington_backed.rb +52 -0
- data/lib/pdfrb/model/cos/dictionary.rb +28 -36
- data/lib/pdfrb/model/cos.rb +1 -0
- data/lib/pdfrb/model/pdf_array.rb +20 -0
- data/lib/pdfrb/model/type/box_color_info.rb +1 -0
- data/lib/pdfrb/model/type/cal_gray.rb +1 -0
- data/lib/pdfrb/model/type/cal_rgb.rb +1 -0
- data/lib/pdfrb/model/type/color_space.rb +230 -0
- data/lib/pdfrb/model/type/crypt_filter.rb +4 -0
- data/lib/pdfrb/model/type/destination.rb +136 -0
- data/lib/pdfrb/model/type/icc_based_color_space.rb +1 -0
- data/lib/pdfrb/model/type/lab.rb +1 -0
- data/lib/pdfrb/model/type/misc_helpers.rb +1 -0
- data/lib/pdfrb/model/type/page_label.rb +1 -0
- data/lib/pdfrb/model/type.rb +31 -0
- data/lib/pdfrb/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bf26e5763a734543b8fd399e6cb67b62b4de9383a94bda13fb3a4bdef0367bc4
|
|
4
|
+
data.tar.gz: 3279da4538b50d9b606b1f275fcdd1e0d2b50e314f0d4d6b65e964db7f30a7c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c216efe24c2fced4764b840296a8292bc6e2b61caf94ac70af32fa7123191b525ad32b2a4110456bfc16a283374102519ce47a69705f629ec20fe099d84a4c25
|
|
7
|
+
data.tar.gz: cf2cb80d6482f117254ee0413c3ea67f215ec0285e759340324d95f27806af5033f547d1165d545e0b05f8ea522f3c51c5e6e5009029ca04a51b9c429a3f5db6
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pdfrb
|
|
4
|
+
module Model
|
|
5
|
+
module Cos
|
|
6
|
+
# Shared Arlington TSV binding for COS container classes.
|
|
7
|
+
# Cos::Dictionary extends this and merges field definitions via
|
|
8
|
+
# define_field; Model::PdfArray extends it and keeps the
|
|
9
|
+
# positional definition for element-type lookup. Either way the
|
|
10
|
+
# class is registered in Pdfrb::Model::Type.arlington_registry
|
|
11
|
+
# so field-link resolution can find it.
|
|
12
|
+
module ArlingtonBacked
|
|
13
|
+
# Pull the named Arlington TSV. Idempotent. Silently no-ops
|
|
14
|
+
# when the Arlington layer or the TSV is unavailable, so
|
|
15
|
+
# hand-coded subclasses still work.
|
|
16
|
+
def arlington_object(name, version: "latest")
|
|
17
|
+
return if arlington_loaded_for?(name)
|
|
18
|
+
return unless arlington_available?
|
|
19
|
+
|
|
20
|
+
definition = Pdfrb::Arlington::Loader.object_definition(name, version: version)
|
|
21
|
+
return unless definition
|
|
22
|
+
|
|
23
|
+
arlington_mark_loaded(name)
|
|
24
|
+
Pdfrb::Model::Type.register_arlington(name, self) if Pdfrb::Model.const_defined?(:Type)
|
|
25
|
+
apply_arlington_definition(definition)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def arlington_loaded_for?(arlington_name)
|
|
29
|
+
@arlington_loaded_name == arlington_name
|
|
30
|
+
end
|
|
31
|
+
private :arlington_loaded_for?
|
|
32
|
+
|
|
33
|
+
def arlington_mark_loaded(name)
|
|
34
|
+
@arlington_loaded_name = name
|
|
35
|
+
end
|
|
36
|
+
private :arlington_mark_loaded
|
|
37
|
+
|
|
38
|
+
def arlington_available?
|
|
39
|
+
Pdfrb.const_defined?(:Arlington) &&
|
|
40
|
+
Pdfrb::Arlington.const_defined?(:Loader)
|
|
41
|
+
rescue StandardError
|
|
42
|
+
false
|
|
43
|
+
end
|
|
44
|
+
private :arlington_available?
|
|
45
|
+
|
|
46
|
+
# Hook: containers override to consume the definition.
|
|
47
|
+
def apply_arlington_definition(_definition); end
|
|
48
|
+
private :apply_arlington_definition
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -13,6 +13,8 @@ module Pdfrb
|
|
|
13
13
|
# via Pdfrb::Arlington::Loader. Calls `define_field` under
|
|
14
14
|
# the hood with types translated to Ruby classes.
|
|
15
15
|
class Dictionary < Pdfrb::Model::Object
|
|
16
|
+
extend ArlingtonBacked
|
|
17
|
+
|
|
16
18
|
# ---- Per-class field registry ----
|
|
17
19
|
|
|
18
20
|
# Shared type registry (s7.7 /Type symbol -> Dictionary
|
|
@@ -69,50 +71,20 @@ module Pdfrb
|
|
|
69
71
|
own_fields.each { |n, f| yield n, f }
|
|
70
72
|
end
|
|
71
73
|
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
-
|
|
75
|
-
#
|
|
76
|
-
# Also registers +self+ in Pdfrb::Model::Type.arlington_registry
|
|
77
|
-
# under +name+ so field-link resolution can find this class
|
|
78
|
-
# when other Types reference it.
|
|
79
|
-
def arlington_object(name, version: "latest")
|
|
80
|
-
return if arlington_loaded_for?(name)
|
|
81
|
-
return unless arlington_available?
|
|
82
|
-
|
|
83
|
-
definition = Pdfrb::Arlington::Loader.object_definition(name, version: version)
|
|
84
|
-
return unless definition
|
|
85
|
-
|
|
86
|
-
arlington_mark_loaded(name)
|
|
87
|
-
Pdfrb::Model::Type.register_arlington(name, self) if Pdfrb::Model.const_defined?(:Type)
|
|
74
|
+
# Merge the TSV's field definitions into the class's field
|
|
75
|
+
# set (ArlingtonBacked#arlington_object hook).
|
|
76
|
+
def apply_arlington_definition(definition)
|
|
88
77
|
definition.each_field do |field_def|
|
|
89
78
|
define_field_from_arlington(field_def)
|
|
90
79
|
end
|
|
91
80
|
end
|
|
81
|
+
private :apply_arlington_definition
|
|
92
82
|
|
|
93
83
|
def own_fields
|
|
94
84
|
@own_fields ||= {}
|
|
95
85
|
end
|
|
96
86
|
private :own_fields
|
|
97
87
|
|
|
98
|
-
def arlington_loaded_for?(arlington_name)
|
|
99
|
-
@arlington_loaded_name == arlington_name
|
|
100
|
-
end
|
|
101
|
-
private :arlington_loaded_for?
|
|
102
|
-
|
|
103
|
-
def arlington_mark_loaded(name)
|
|
104
|
-
@arlington_loaded_name = name
|
|
105
|
-
end
|
|
106
|
-
private :arlington_mark_loaded
|
|
107
|
-
|
|
108
|
-
def arlington_available?
|
|
109
|
-
Pdfrb.const_defined?(:Arlington) &&
|
|
110
|
-
Pdfrb::Arlington.const_defined?(:Loader)
|
|
111
|
-
rescue StandardError
|
|
112
|
-
false
|
|
113
|
-
end
|
|
114
|
-
private :arlington_available?
|
|
115
|
-
|
|
116
88
|
# Merge Arlington field metadata with any hand-coded
|
|
117
89
|
# define_field declaration. Hand-coded fields win: if the
|
|
118
90
|
# class already declares this key explicitly (with a type),
|
|
@@ -192,12 +164,32 @@ module Pdfrb
|
|
|
192
164
|
private :arlington_required?
|
|
193
165
|
|
|
194
166
|
def arlington_default(field_def)
|
|
195
|
-
|
|
167
|
+
raw = field_def.default_value
|
|
168
|
+
return nil if raw.nil?
|
|
169
|
+
return raw unless raw.is_a?(::String)
|
|
170
|
+
|
|
171
|
+
if raw.start_with?("[") && raw.end_with?("]")
|
|
172
|
+
return raw[1..-2].split.then { |tokens| tokens.map { |t| arlington_scalar(t) } }
|
|
173
|
+
end
|
|
196
174
|
|
|
197
|
-
|
|
175
|
+
arlington_scalar(raw)
|
|
198
176
|
end
|
|
199
177
|
private :arlington_default
|
|
200
178
|
|
|
179
|
+
# TSV default cells are raw strings; convert per scalar
|
|
180
|
+
# shape so typed access returns Integer/Symbol/etc.
|
|
181
|
+
def arlington_scalar(token)
|
|
182
|
+
case token
|
|
183
|
+
when "true" then true
|
|
184
|
+
when "false" then false
|
|
185
|
+
when "null" then nil
|
|
186
|
+
when /\A-?\d+\z/ then Integer(token, 10)
|
|
187
|
+
when /\A-?\d+\.\d+\z/ then Float(token)
|
|
188
|
+
else token
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
private :arlington_scalar
|
|
192
|
+
|
|
201
193
|
def arlington_version(field_def)
|
|
202
194
|
field_def.since_version.to_s
|
|
203
195
|
end
|
data/lib/pdfrb/model/cos.rb
CHANGED
|
@@ -8,6 +8,26 @@ module Pdfrb
|
|
|
8
8
|
# when nested inside a typed Dictionary (field-driven).
|
|
9
9
|
class PdfArray < Pdfrb::Model::Object
|
|
10
10
|
include Enumerable
|
|
11
|
+
extend Cos::ArlingtonBacked
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
# ArlingtonBacked hook: array TSVs describe positional element
|
|
15
|
+
# types (keys "0", "1", ...), so keep the definition whole
|
|
16
|
+
# rather than merging per-field metadata.
|
|
17
|
+
def apply_arlington_definition(definition)
|
|
18
|
+
@arlington_definition = definition
|
|
19
|
+
end
|
|
20
|
+
private :apply_arlington_definition
|
|
21
|
+
|
|
22
|
+
def arlington_definition
|
|
23
|
+
@arlington_definition
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# FieldDefinition for the element at +index+, per the TSV.
|
|
27
|
+
def element_field(index)
|
|
28
|
+
arlington_definition&.field_for(index.to_s)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
11
31
|
|
|
12
32
|
def initialize(arr = [], oid: 0, gen: 0, document: nil)
|
|
13
33
|
super(Array(arr), oid: oid, gen: gen, document: document)
|
|
@@ -7,6 +7,7 @@ module Pdfrb
|
|
|
7
7
|
# visual guide lines for page boxes (crop, bleed, trim, art) in
|
|
8
8
|
# the viewer. Lives on Page /BoxColorInfo.
|
|
9
9
|
class BoxColorInfo < Pdfrb::Model::Cos::Dictionary
|
|
10
|
+
arlington_object "BoxColorInfo"
|
|
10
11
|
def crop_box_style; self[:CropBox]; end
|
|
11
12
|
def bleed_box_style; self[:BleedBox]; end
|
|
12
13
|
def trim_box_style; self[:TrimBox]; end
|
|
@@ -6,6 +6,7 @@ module Pdfrb
|
|
|
6
6
|
# CalGray color space dictionary (s8.6.3.2). Single-component
|
|
7
7
|
# calibrated grayscale: [/CalGray <dict>].
|
|
8
8
|
class CalGray < Pdfrb::Model::Cos::Dictionary
|
|
9
|
+
arlington_object "CalGrayDict"
|
|
9
10
|
def white_point; self[:WhitePoint]; end
|
|
10
11
|
def black_point; self[:BlackPoint]; end
|
|
11
12
|
def gamma; self[:Gamma] || 1.0; end
|
|
@@ -6,6 +6,7 @@ module Pdfrb
|
|
|
6
6
|
# CalRGB color space dictionary (s8.6.3.3). Calibrated RGB:
|
|
7
7
|
# [/CalRGB <dict>].
|
|
8
8
|
class CalRGB < Pdfrb::Model::Cos::Dictionary
|
|
9
|
+
arlington_object "CalRGBDict"
|
|
9
10
|
def white_point; self[:WhitePoint]; end
|
|
10
11
|
def black_point; self[:BlackPoint]; end
|
|
11
12
|
def gamma; self[:Gamma]; end
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pdfrb
|
|
4
|
+
module Model
|
|
5
|
+
module Type
|
|
6
|
+
# Array-form color spaces (s8.6). A color space is either a
|
|
7
|
+
# single /Name (device spaces) or an array [family *params]
|
|
8
|
+
# whose first element names the family.
|
|
9
|
+
class ColorSpace < Pdfrb::Model::PdfArray
|
|
10
|
+
def family; self[0]; end
|
|
11
|
+
|
|
12
|
+
def device?
|
|
13
|
+
size == 1
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def based?
|
|
17
|
+
size > 1
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# [/CalGray <dict>] (s8.6.3.2).
|
|
22
|
+
class CalGrayColorSpace < ColorSpace
|
|
23
|
+
arlington_object "CalGrayColorSpace"
|
|
24
|
+
|
|
25
|
+
def cal_gray_dict; self[1]; end
|
|
26
|
+
|
|
27
|
+
def gamma
|
|
28
|
+
cal_gray_dict && cal_gray_dict[:Gamma] ? cal_gray_dict[:Gamma] : 1.0
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# [/CalRGB <dict>] (s8.6.3.3).
|
|
33
|
+
class CalRGBColorSpace < ColorSpace
|
|
34
|
+
arlington_object "CalRGBColorSpace"
|
|
35
|
+
|
|
36
|
+
def cal_rgb_dict; self[1]; end
|
|
37
|
+
|
|
38
|
+
def gamma
|
|
39
|
+
cal_rgb_dict && cal_rgb_dict[:Gamma]
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# [/Lab <dict>] (s8.6.3.4).
|
|
44
|
+
class LabColorSpace < ColorSpace
|
|
45
|
+
arlington_object "LabColorSpace"
|
|
46
|
+
|
|
47
|
+
def lab_dict; self[1]; end
|
|
48
|
+
|
|
49
|
+
def range
|
|
50
|
+
lab_dict && lab_dict[:Range]
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# [/DeviceGray] etc. (s8.6.4). Single-name device spaces.
|
|
55
|
+
class DeviceGrayColorSpace < ColorSpace
|
|
56
|
+
arlington_object "DeviceGrayColorSpace"
|
|
57
|
+
|
|
58
|
+
def components; 1; end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class DeviceRGBColorSpace < ColorSpace
|
|
62
|
+
arlington_object "DeviceRGBColorSpace"
|
|
63
|
+
|
|
64
|
+
def components; 3; end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class DeviceCMYKColorSpace < ColorSpace
|
|
68
|
+
arlington_object "DeviceCMYKColorSpace"
|
|
69
|
+
|
|
70
|
+
def components; 4; end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# [/ICCBased <stream>] (s8.6.5.5).
|
|
74
|
+
class ICCBasedColorSpaceArray < ColorSpace
|
|
75
|
+
arlington_object "ICCBasedColorSpace"
|
|
76
|
+
|
|
77
|
+
def profile_stream; self[1]; end
|
|
78
|
+
|
|
79
|
+
def profile_hash?
|
|
80
|
+
profile_stream.is_a?(Pdfrb::Model::Cos::Stream) ||
|
|
81
|
+
profile_stream.is_a?(::Hash)
|
|
82
|
+
end
|
|
83
|
+
private :profile_hash?
|
|
84
|
+
|
|
85
|
+
def components
|
|
86
|
+
profile_hash? ? profile_stream[:N] : nil
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def alternate_space
|
|
90
|
+
profile_hash? ? profile_stream[:Alternate] : nil
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# [/Indexed base hival lookup] (s8.6.6.3).
|
|
95
|
+
class IndexedColorSpace < ColorSpace
|
|
96
|
+
arlington_object "IndexedColorSpace"
|
|
97
|
+
|
|
98
|
+
def base; self[1]; end
|
|
99
|
+
def hival; self[2]; end
|
|
100
|
+
def lookup; self[3]; end
|
|
101
|
+
|
|
102
|
+
def components; 1; end
|
|
103
|
+
|
|
104
|
+
def lookup_length
|
|
105
|
+
data = lookup
|
|
106
|
+
return data.bytesize if data.is_a?(::String)
|
|
107
|
+
|
|
108
|
+
data.is_a?(Pdfrb::Model::Cos::Stream) ? nil : data&.size
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# [/Separation name alternate tint] (s8.6.6.4).
|
|
113
|
+
class SeparationColorSpace < ColorSpace
|
|
114
|
+
arlington_object "SeparationColorSpace"
|
|
115
|
+
|
|
116
|
+
def colorant_name; self[1]; end
|
|
117
|
+
def alternate_space; self[2]; end
|
|
118
|
+
def tint_transform; self[3]; end
|
|
119
|
+
|
|
120
|
+
def components; 1; end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# [/DeviceN names alternate tint attrs] (s8.6.6.5).
|
|
124
|
+
class DeviceNColorSpace < ColorSpace
|
|
125
|
+
arlington_object "DeviceNColorSpace"
|
|
126
|
+
|
|
127
|
+
def colorant_names
|
|
128
|
+
names = self[1]
|
|
129
|
+
names.is_a?(Pdfrb::Model::PdfArray) ? names.to_a : names
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def alternate_space; self[2]; end
|
|
133
|
+
def tint_transform; self[3]; end
|
|
134
|
+
def attributes; self[4]; end
|
|
135
|
+
|
|
136
|
+
def components
|
|
137
|
+
names = self[1]
|
|
138
|
+
return 1 unless names.is_a?(Pdfrb::Model::PdfArray) || names.is_a?(::Array)
|
|
139
|
+
|
|
140
|
+
names.size
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# [/Pattern [base]] (s8.7.3.3). With a base space the pattern
|
|
145
|
+
# is a colored-with-tint (uncolored) pattern family.
|
|
146
|
+
class PatternColorSpace < ColorSpace
|
|
147
|
+
arlington_object "PatternColorSpace"
|
|
148
|
+
|
|
149
|
+
def base_space; self[1]; end
|
|
150
|
+
|
|
151
|
+
def uncolored?
|
|
152
|
+
!base_space.nil?
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Black point [X Y Z] inside CalGray/CalRGB/Lab dicts
|
|
157
|
+
# (s8.6.3.1).
|
|
158
|
+
class BlackpointArray < Pdfrb::Model::PdfArray
|
|
159
|
+
arlington_object "BlackpointArray"
|
|
160
|
+
|
|
161
|
+
def x; self[0]; end
|
|
162
|
+
def y; self[1]; end
|
|
163
|
+
def z; self[2]; end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Resources /ColorSpace dictionary (s7.8.3). Maps resource
|
|
167
|
+
# names to color spaces; also carries the device-space
|
|
168
|
+
# defaults /DefaultGray, /DefaultRGB, /DefaultCMYK.
|
|
169
|
+
class ColorSpaceMap < Pdfrb::Model::Cos::Dictionary
|
|
170
|
+
arlington_object "ColorSpaceMap"
|
|
171
|
+
|
|
172
|
+
def [](name)
|
|
173
|
+
value[name.to_sym] || value[name.to_s]
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def add(name, color_space)
|
|
177
|
+
value[name.to_sym] = color_space
|
|
178
|
+
name.to_sym
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def default_gray; self[:DefaultGray]; end
|
|
182
|
+
def default_rgb; self[:DefaultRGB]; end
|
|
183
|
+
def default_cmyk; self[:DefaultCMYK]; end
|
|
184
|
+
|
|
185
|
+
def each_color_space(&)
|
|
186
|
+
return enum_for(:each_color_space) unless block_given?
|
|
187
|
+
|
|
188
|
+
value.each(&)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def names
|
|
192
|
+
value.keys
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Colorants dictionary (s8.6.6.5, DeviceN /Colorants). Maps
|
|
197
|
+
# individual colorant names to Separation spaces.
|
|
198
|
+
class ColorantsDict < Pdfrb::Model::Cos::Dictionary
|
|
199
|
+
arlington_object "ColorantsDict"
|
|
200
|
+
|
|
201
|
+
def [](name)
|
|
202
|
+
value[name.to_sym] || value[name.to_s]
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def each_colorant(&)
|
|
206
|
+
return enum_for(:each_colorant) unless block_given?
|
|
207
|
+
|
|
208
|
+
value.each(&)
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def colorant_names
|
|
212
|
+
value.keys
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Box style dictionary (s7.11.4, BoxColorInfo entries). Guides
|
|
217
|
+
# for the viewer's page-box display.
|
|
218
|
+
class BoxStyle < Pdfrb::Model::Cos::Dictionary
|
|
219
|
+
arlington_object "BoxStyle"
|
|
220
|
+
|
|
221
|
+
def color; self[:C]; end
|
|
222
|
+
def width; self[:W] || 1; end
|
|
223
|
+
def style; self[:S]&.to_sym || :S; end
|
|
224
|
+
def dash; self[:D]; end
|
|
225
|
+
|
|
226
|
+
def dashed?; style == :D; end
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
end
|
|
@@ -6,6 +6,7 @@ module Pdfrb
|
|
|
6
6
|
# Crypt Filter (s7.6.5). Per-stream cipher filter spec — names
|
|
7
7
|
# the cipher and authentication event.
|
|
8
8
|
class CryptFilter < Pdfrb::Model::Cos::Dictionary
|
|
9
|
+
arlington_object "CryptFilter"
|
|
9
10
|
def cipher_method; self[:CFM]&.to_sym; end
|
|
10
11
|
def auth_event; self[:AuthEvent]&.to_sym; end
|
|
11
12
|
def length; self[:Length]; end
|
|
@@ -27,6 +28,7 @@ module Pdfrb
|
|
|
27
28
|
# Crypt Filter Map (s7.6.5, Table 26). Maps per-page crypt filter
|
|
28
29
|
# names to the default CryptFilter used.
|
|
29
30
|
class CryptFilterMap < Pdfrb::Model::Cos::Dictionary
|
|
31
|
+
arlington_object "CryptFilterMap"
|
|
30
32
|
def filter_for(stream_name)
|
|
31
33
|
value[stream_name.to_sym] || value[stream_name.to_s]
|
|
32
34
|
end
|
|
@@ -41,6 +43,7 @@ module Pdfrb
|
|
|
41
43
|
# Crypt Filter Public Key (s7.6.5, Table 26). Public-key analog
|
|
42
44
|
# of CryptFilter.
|
|
43
45
|
class CryptFilterPublicKey < Pdfrb::Model::Cos::Dictionary
|
|
46
|
+
arlington_object "CryptFilterPublicKey"
|
|
44
47
|
def cipher_method; self[:CFM]&.to_sym; end
|
|
45
48
|
def auth_event; self[:AuthEvent]&.to_sym; end
|
|
46
49
|
def recipients; self[:Recipients]; end
|
|
@@ -49,6 +52,7 @@ module Pdfrb
|
|
|
49
52
|
# Crypt Filter Public Key Map (s7.6.5, Table 26). Maps per-page
|
|
50
53
|
# public-key crypt filters.
|
|
51
54
|
class CryptFilterPublicKeyMap < Pdfrb::Model::Cos::Dictionary
|
|
55
|
+
arlington_object "CryptFilterPublicKeyMap"
|
|
52
56
|
def filter_for(stream_name)
|
|
53
57
|
value[stream_name.to_sym] || value[stream_name.to_s]
|
|
54
58
|
end
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pdfrb
|
|
4
|
+
module Model
|
|
5
|
+
module Type
|
|
6
|
+
# Explicit destination array [page, display_type, *params]
|
|
7
|
+
# (s12.3.2.2). Element 0 is a page reference (or integer page
|
|
8
|
+
# number); element 1 names the display mode.
|
|
9
|
+
class Destination < Pdfrb::Model::PdfArray
|
|
10
|
+
def page_ref; self[0]; end
|
|
11
|
+
def display_type; self[1]; end
|
|
12
|
+
|
|
13
|
+
# True when element 0 is an integer page number (GoTo D form).
|
|
14
|
+
def page_number?
|
|
15
|
+
page_ref.is_a?(Integer)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def page_number
|
|
19
|
+
page_ref if page_number?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def xyz?; display_type == :XYZ; end
|
|
23
|
+
def fit?; display_type == :Fit; end
|
|
24
|
+
def fit_h?; display_type == :FitH; end
|
|
25
|
+
def fit_v?; display_type == :FitV; end
|
|
26
|
+
def fit_r?; display_type == :FitR; end
|
|
27
|
+
def fit_b?; display_type == :FitB; end
|
|
28
|
+
def fit_bh?; display_type == :FitBH; end
|
|
29
|
+
def fit_bv?; display_type == :FitBV; end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# [page, :XYZ, left, top, zoom] — window positioned at a point
|
|
33
|
+
# (s12.3.2.2, Table 151).
|
|
34
|
+
class DestinationXYZ < Destination
|
|
35
|
+
arlington_object "DestXYZArray"
|
|
36
|
+
|
|
37
|
+
def left; self[2]; end
|
|
38
|
+
def top; self[3]; end
|
|
39
|
+
def zoom; self[4]; end
|
|
40
|
+
|
|
41
|
+
def retains_position?
|
|
42
|
+
left.nil? && top.nil?
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# [page, :Fit] — whole page fits the window (s12.3.2.2).
|
|
47
|
+
class DestinationFit < Destination
|
|
48
|
+
arlington_object "Dest0Array"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# [page, :FitH, top] — page width fits the window (s12.3.2.2).
|
|
52
|
+
class DestinationFitH < Destination
|
|
53
|
+
arlington_object "Dest1Array"
|
|
54
|
+
|
|
55
|
+
def top; self[2]; end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# [page, :FitR, left, bottom, right, top] — rectangle fits the
|
|
59
|
+
# window (s12.3.2.2).
|
|
60
|
+
class DestinationFitR < Destination
|
|
61
|
+
arlington_object "Dest4Array"
|
|
62
|
+
|
|
63
|
+
def left; self[2]; end
|
|
64
|
+
def bottom; self[3]; end
|
|
65
|
+
def right; self[4]; end
|
|
66
|
+
def top; self[5]; end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Structure-destination variants (s7.9.4, PDF 1.3+ tagging).
|
|
70
|
+
# Element 0 may be a structure element reference (string) instead
|
|
71
|
+
# of a page — used by GoToE /D chains with structure content.
|
|
72
|
+
class DestinationXYZStruct < DestinationXYZ
|
|
73
|
+
arlington_object "DestXYZStructArray"
|
|
74
|
+
|
|
75
|
+
def struct_ref?; page_ref.is_a?(String); end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
class DestinationFitStruct < DestinationFit
|
|
79
|
+
arlington_object "Dest0StructArray"
|
|
80
|
+
|
|
81
|
+
def struct_ref?; page_ref.is_a?(String); end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
class DestinationFitHStruct < DestinationFitH
|
|
85
|
+
arlington_object "Dest1StructArray"
|
|
86
|
+
|
|
87
|
+
def struct_ref?; page_ref.is_a?(String); end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
class DestinationFitRStruct < DestinationFitR
|
|
91
|
+
arlington_object "Dest4StructArray"
|
|
92
|
+
|
|
93
|
+
def struct_ref?; page_ref.is_a?(String); end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Destination dictionary (s12.3.2.3). Wraps a destination in
|
|
97
|
+
# target-dictionary chains (GoToE /D). /SD is the structure
|
|
98
|
+
# destination form.
|
|
99
|
+
class DestinationDict < Pdfrb::Model::Cos::Dictionary
|
|
100
|
+
arlington_object "DestDict"
|
|
101
|
+
|
|
102
|
+
def d; self[:D]; end
|
|
103
|
+
def sd; self[:SD]; end
|
|
104
|
+
|
|
105
|
+
def structure_destination?
|
|
106
|
+
!sd.nil?
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# /Dests dictionary (s7.7.4, deprecated 2.0). Name → destination
|
|
111
|
+
# map living on the (page or) catalog.
|
|
112
|
+
class DestsMap < Pdfrb::Model::Cos::Dictionary
|
|
113
|
+
arlington_object "DestsMap"
|
|
114
|
+
|
|
115
|
+
def [](name)
|
|
116
|
+
value[name.to_sym] || value[name.to_s]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def add(name, destination)
|
|
120
|
+
value[name.to_sym] = destination
|
|
121
|
+
name.to_sym
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def each_destination(&)
|
|
125
|
+
return enum_for(:each_destination) unless block_given?
|
|
126
|
+
|
|
127
|
+
value.each(&)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def names
|
|
131
|
+
value.keys
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
@@ -6,6 +6,7 @@ module Pdfrb
|
|
|
6
6
|
# ICCBased Color Space (s8.6.5.5). Wrapper for the
|
|
7
7
|
# [/ICCBased <stream-ref>] array form.
|
|
8
8
|
class ICCBasedColorSpace < Pdfrb::Model::Cos::Stream
|
|
9
|
+
arlington_object "ICCProfileStream"
|
|
9
10
|
def component_count; self[:N]; end
|
|
10
11
|
def alternate; self[:Alternate]; end
|
|
11
12
|
def range; self[:Range]; end
|
data/lib/pdfrb/model/type/lab.rb
CHANGED
|
@@ -6,6 +6,7 @@ module Pdfrb
|
|
|
6
6
|
# Lab color space dictionary (s8.6.3.4). CIE L*a*b*:
|
|
7
7
|
# [/Lab <dict>].
|
|
8
8
|
class Lab < Pdfrb::Model::Cos::Dictionary
|
|
9
|
+
arlington_object "LabDict"
|
|
9
10
|
def white_point; self[:WhitePoint]; end
|
|
10
11
|
def black_point; self[:BlackPoint]; end
|
|
11
12
|
def range; self[:Range]; end
|
|
@@ -27,6 +27,7 @@ module Pdfrb
|
|
|
27
27
|
# Lab Range Array [a_min a_max b_min b_max]. Used inside the
|
|
28
28
|
# Lab color space dict (s8.6.3.4).
|
|
29
29
|
class LabRangeArray < Pdfrb::Model::PdfArray
|
|
30
|
+
arlington_object "LabRangeArray"
|
|
30
31
|
def a_min; self[0]; end
|
|
31
32
|
def a_max; self[1]; end
|
|
32
33
|
def b_min; self[2]; end
|
data/lib/pdfrb/model/type.rb
CHANGED
|
@@ -311,6 +311,37 @@ module Pdfrb
|
|
|
311
311
|
autoload :OutputIntentsContainer, "pdfrb/model/type/misc_helpers"
|
|
312
312
|
autoload :CMapStream, "pdfrb/model/type/misc_helpers"
|
|
313
313
|
|
|
314
|
+
# Explicit destination arrays + maps (s12.3.2).
|
|
315
|
+
autoload :Destination, "pdfrb/model/type/destination"
|
|
316
|
+
autoload :DestinationXYZ, "pdfrb/model/type/destination"
|
|
317
|
+
autoload :DestinationFit, "pdfrb/model/type/destination"
|
|
318
|
+
autoload :DestinationFitH, "pdfrb/model/type/destination"
|
|
319
|
+
autoload :DestinationFitR, "pdfrb/model/type/destination"
|
|
320
|
+
autoload :DestinationXYZStruct, "pdfrb/model/type/destination"
|
|
321
|
+
autoload :DestinationFitStruct, "pdfrb/model/type/destination"
|
|
322
|
+
autoload :DestinationFitHStruct, "pdfrb/model/type/destination"
|
|
323
|
+
autoload :DestinationFitRStruct, "pdfrb/model/type/destination"
|
|
324
|
+
autoload :DestinationDict, "pdfrb/model/type/destination"
|
|
325
|
+
autoload :DestsMap, "pdfrb/model/type/destination"
|
|
326
|
+
|
|
327
|
+
# Array-form color spaces + maps (s8.6).
|
|
328
|
+
autoload :ColorSpace, "pdfrb/model/type/color_space"
|
|
329
|
+
autoload :CalGrayColorSpace, "pdfrb/model/type/color_space"
|
|
330
|
+
autoload :CalRGBColorSpace, "pdfrb/model/type/color_space"
|
|
331
|
+
autoload :LabColorSpace, "pdfrb/model/type/color_space"
|
|
332
|
+
autoload :DeviceGrayColorSpace, "pdfrb/model/type/color_space"
|
|
333
|
+
autoload :DeviceRGBColorSpace, "pdfrb/model/type/color_space"
|
|
334
|
+
autoload :DeviceCMYKColorSpace, "pdfrb/model/type/color_space"
|
|
335
|
+
autoload :ICCBasedColorSpaceArray, "pdfrb/model/type/color_space"
|
|
336
|
+
autoload :IndexedColorSpace, "pdfrb/model/type/color_space"
|
|
337
|
+
autoload :SeparationColorSpace, "pdfrb/model/type/color_space"
|
|
338
|
+
autoload :DeviceNColorSpace, "pdfrb/model/type/color_space"
|
|
339
|
+
autoload :PatternColorSpace, "pdfrb/model/type/color_space"
|
|
340
|
+
autoload :BlackpointArray, "pdfrb/model/type/color_space"
|
|
341
|
+
autoload :ColorSpaceMap, "pdfrb/model/type/color_space"
|
|
342
|
+
autoload :ColorantsDict, "pdfrb/model/type/color_space"
|
|
343
|
+
autoload :BoxStyle, "pdfrb/model/type/color_space"
|
|
344
|
+
|
|
314
345
|
# Crypt filter (s7.6.5).
|
|
315
346
|
autoload :CryptFilter, "pdfrb/model/type/crypt_filter"
|
|
316
347
|
autoload :CryptFilterMap, "pdfrb/model/type/crypt_filter"
|
data/lib/pdfrb/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pdfrb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.26
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -941,6 +941,7 @@ files:
|
|
|
941
941
|
- lib/pdfrb/linearization/writer.rb
|
|
942
942
|
- lib/pdfrb/model.rb
|
|
943
943
|
- lib/pdfrb/model/cos.rb
|
|
944
|
+
- lib/pdfrb/model/cos/arlington_backed.rb
|
|
944
945
|
- lib/pdfrb/model/cos/dictionary.rb
|
|
945
946
|
- lib/pdfrb/model/cos/fields.rb
|
|
946
947
|
- lib/pdfrb/model/cos/name_encoding.rb
|
|
@@ -1015,8 +1016,10 @@ files:
|
|
|
1015
1016
|
- lib/pdfrb/model/type/collection_sort.rb
|
|
1016
1017
|
- lib/pdfrb/model/type/collection_split.rb
|
|
1017
1018
|
- lib/pdfrb/model/type/collection_subitem.rb
|
|
1019
|
+
- lib/pdfrb/model/type/color_space.rb
|
|
1018
1020
|
- lib/pdfrb/model/type/crypt_filter.rb
|
|
1019
1021
|
- lib/pdfrb/model/type/d_part.rb
|
|
1022
|
+
- lib/pdfrb/model/type/destination.rb
|
|
1020
1023
|
- lib/pdfrb/model/type/device_n.rb
|
|
1021
1024
|
- lib/pdfrb/model/type/device_n_mixing_hints.rb
|
|
1022
1025
|
- lib/pdfrb/model/type/device_n_process.rb
|