pdfrb 0.7.25 → 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/dictionary.rb +22 -2
- 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/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 +18 -0
- data/lib/pdfrb/version.rb +1 -1
- metadata +3 -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
|
|
@@ -164,12 +164,32 @@ module Pdfrb
|
|
|
164
164
|
private :arlington_required?
|
|
165
165
|
|
|
166
166
|
def arlington_default(field_def)
|
|
167
|
-
|
|
167
|
+
raw = field_def.default_value
|
|
168
|
+
return nil if raw.nil?
|
|
169
|
+
return raw unless raw.is_a?(::String)
|
|
168
170
|
|
|
169
|
-
|
|
171
|
+
if raw.start_with?("[") && raw.end_with?("]")
|
|
172
|
+
return raw[1..-2].split.then { |tokens| tokens.map { |t| arlington_scalar(t) } }
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
arlington_scalar(raw)
|
|
170
176
|
end
|
|
171
177
|
private :arlington_default
|
|
172
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
|
+
|
|
173
193
|
def arlington_version(field_def)
|
|
174
194
|
field_def.since_version.to_s
|
|
175
195
|
end
|
|
@@ -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
|
# 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
|
@@ -324,6 +324,24 @@ module Pdfrb
|
|
|
324
324
|
autoload :DestinationDict, "pdfrb/model/type/destination"
|
|
325
325
|
autoload :DestsMap, "pdfrb/model/type/destination"
|
|
326
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
|
+
|
|
327
345
|
# Crypt filter (s7.6.5).
|
|
328
346
|
autoload :CryptFilter, "pdfrb/model/type/crypt_filter"
|
|
329
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
|
|
@@ -1016,6 +1016,7 @@ files:
|
|
|
1016
1016
|
- lib/pdfrb/model/type/collection_sort.rb
|
|
1017
1017
|
- lib/pdfrb/model/type/collection_split.rb
|
|
1018
1018
|
- lib/pdfrb/model/type/collection_subitem.rb
|
|
1019
|
+
- lib/pdfrb/model/type/color_space.rb
|
|
1019
1020
|
- lib/pdfrb/model/type/crypt_filter.rb
|
|
1020
1021
|
- lib/pdfrb/model/type/d_part.rb
|
|
1021
1022
|
- lib/pdfrb/model/type/destination.rb
|