pdf-reader 2.8.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/lib/pdf/reader/aes_v2_security_handler.rb +41 -0
- data/lib/pdf/reader/aes_v3_security_handler.rb +38 -0
- data/lib/pdf/reader/buffer.rb +36 -34
- data/lib/pdf/reader/cmap.rb +64 -51
- data/lib/pdf/reader/error.rb +8 -0
- data/lib/pdf/reader/filter/ascii85.rb +1 -1
- data/lib/pdf/reader/filter/ascii_hex.rb +1 -1
- data/lib/pdf/reader/filter/depredict.rb +1 -1
- data/lib/pdf/reader/filter/flate.rb +3 -3
- data/lib/pdf/reader/filter/lzw.rb +1 -1
- data/lib/pdf/reader/filter/null.rb +1 -2
- data/lib/pdf/reader/filter/run_length.rb +1 -1
- data/lib/pdf/reader/filter.rb +1 -1
- data/lib/pdf/reader/font.rb +29 -17
- data/lib/pdf/reader/font_descriptor.rb +18 -17
- data/lib/pdf/reader/form_xobject.rb +14 -5
- data/lib/pdf/reader/key_builder_v5.rb +138 -0
- data/lib/pdf/reader/null_security_handler.rb +0 -4
- data/lib/pdf/reader/object_hash.rb +247 -42
- data/lib/pdf/reader/page.rb +38 -20
- data/lib/pdf/reader/page_state.rb +1 -1
- data/lib/pdf/reader/page_text_receiver.rb +4 -1
- data/lib/pdf/reader/parser.rb +9 -6
- data/lib/pdf/reader/point.rb +1 -1
- data/lib/pdf/reader/rc4_security_handler.rb +38 -0
- data/lib/pdf/reader/rectangle.rb +2 -2
- data/lib/pdf/reader/{resource_methods.rb → resources.rb} +15 -13
- data/lib/pdf/reader/security_handler_factory.rb +79 -0
- data/lib/pdf/reader/{standard_security_handler.rb → standard_key_builder.rb} +23 -95
- data/lib/pdf/reader/stream.rb +2 -2
- data/lib/pdf/reader/type_check.rb +52 -0
- data/lib/pdf/reader/validating_receiver.rb +262 -0
- data/lib/pdf/reader/width_calculator/true_type.rb +1 -1
- data/lib/pdf/reader/xref.rb +20 -3
- data/lib/pdf/reader.rb +17 -9
- data/rbi/pdf-reader.rbi +388 -173
- metadata +15 -9
- data/lib/pdf/reader/standard_security_handler_v5.rb +0 -92
data/rbi/pdf-reader.rbi
CHANGED
@@ -43,9 +43,28 @@ module PDF
|
|
43
43
|
sig { returns(T::Hash[Symbol, T.untyped]) }
|
44
44
|
def root; end
|
45
45
|
|
46
|
-
class
|
47
|
-
|
46
|
+
class AesV2SecurityHandler
|
47
|
+
sig { params(key: String).void }
|
48
|
+
def initialize(key)
|
49
|
+
@encrypt_key = T.let(T.unsafe(nil), String)
|
50
|
+
end
|
51
|
+
|
52
|
+
sig { params(buf: String, ref: PDF::Reader::Reference).returns(String) }
|
53
|
+
def decrypt(buf, ref); end
|
54
|
+
end
|
55
|
+
|
56
|
+
class AesV3SecurityHandler
|
57
|
+
sig { params(key: String).void }
|
58
|
+
def initialize(key)
|
59
|
+
@encrypt_key = T.let(T.unsafe(nil), String)
|
60
|
+
@cipher = T.let(T.unsafe(nil), String)
|
61
|
+
end
|
62
|
+
|
63
|
+
sig { params(buf: String, ref: PDF::Reader::Reference).returns(String) }
|
64
|
+
def decrypt(buf, ref); end
|
65
|
+
end
|
48
66
|
|
67
|
+
class BoundingRectangleRunsFilter
|
49
68
|
sig { params(runs: T::Array[PDF::Reader::TextRun], rect: PDF::Reader::Rectangle).returns(T::Array[PDF::Reader::TextRun]) }
|
50
69
|
def self.runs_within_rect(runs, rect); end
|
51
70
|
end
|
@@ -65,67 +84,67 @@ module PDF
|
|
65
84
|
WHITE_SPACE = [LF, CR, ' ']
|
66
85
|
TRAILING_BYTECOUNT = 5000
|
67
86
|
|
68
|
-
sig { returns(
|
87
|
+
sig { returns(Integer) }
|
69
88
|
attr_reader :pos
|
70
89
|
|
71
|
-
sig { params(io: T.
|
72
|
-
def initialize(io, opts = {})
|
90
|
+
sig { params(io: T.any(StringIO, File), opts: T::Hash[Symbol, T.untyped]).void }
|
91
|
+
def initialize(io, opts = {})
|
92
|
+
@pos = T.let(T.unsafe(nil), Integer)
|
93
|
+
@tokens = T.let(T.unsafe(nil), T::Array[T.any(String, PDF::Reader::Reference)])
|
94
|
+
@io = T.let(T.unsafe(nil), T.any(StringIO, File))
|
95
|
+
@in_content_stream = T.let(T.unsafe(nil), T::Boolean)
|
96
|
+
end
|
73
97
|
|
74
|
-
sig { returns(T
|
98
|
+
sig { returns(T::Boolean) }
|
75
99
|
def empty?; end
|
76
100
|
|
77
|
-
sig { params(bytes:
|
101
|
+
sig { params(bytes: Integer, opts: T::Hash[Symbol, T.untyped]).returns(T.nilable(String)) }
|
78
102
|
def read(bytes, opts = {}); end
|
79
103
|
|
80
|
-
sig { returns(T.
|
104
|
+
sig { returns(T.any(NilClass, String, PDF::Reader::Reference)) }
|
81
105
|
def token; end
|
82
106
|
|
83
|
-
sig { returns(
|
107
|
+
sig { returns(Integer) }
|
84
108
|
def find_first_xref_offset; end
|
85
109
|
|
86
|
-
sig {
|
110
|
+
sig { void }
|
87
111
|
def check_size_is_non_zero; end
|
88
112
|
|
89
|
-
sig { returns(T
|
113
|
+
sig { returns(T::Boolean) }
|
90
114
|
def in_content_stream?; end
|
91
115
|
|
92
|
-
sig {
|
116
|
+
sig { void }
|
93
117
|
def reset_pos; end
|
94
118
|
|
95
|
-
sig {
|
119
|
+
sig { void }
|
96
120
|
def save_pos; end
|
97
121
|
|
98
|
-
sig {
|
122
|
+
sig { void }
|
99
123
|
def prepare_tokens; end
|
100
124
|
|
101
|
-
sig { returns(
|
125
|
+
sig { returns(Symbol) }
|
102
126
|
def state; end
|
103
127
|
|
104
|
-
sig {
|
128
|
+
sig { void }
|
105
129
|
def merge_indirect_reference; end
|
106
130
|
|
107
|
-
sig {
|
131
|
+
sig { void }
|
108
132
|
def prepare_inline_token; end
|
109
133
|
|
110
|
-
sig {
|
134
|
+
sig { void }
|
111
135
|
def prepare_hex_token; end
|
112
136
|
|
113
|
-
sig {
|
137
|
+
sig { void }
|
114
138
|
def prepare_literal_token; end
|
115
139
|
|
116
|
-
sig {
|
140
|
+
sig { void }
|
117
141
|
def prepare_regular_token; end
|
118
142
|
|
119
|
-
sig { returns(T.
|
143
|
+
sig { returns(T.nilable(Integer)) }
|
120
144
|
def peek_byte; end
|
121
|
-
|
122
|
-
sig { params(token: T.untyped).returns(T.untyped) }
|
123
|
-
def string_token(token); end
|
124
145
|
end
|
125
146
|
|
126
147
|
class CidWidths
|
127
|
-
extend Forwardable
|
128
|
-
|
129
148
|
sig { params(default: T.untyped, array: T.untyped).void }
|
130
149
|
def initialize(default, array); end
|
131
150
|
|
@@ -140,7 +159,6 @@ module PDF
|
|
140
159
|
end
|
141
160
|
|
142
161
|
class CMap
|
143
|
-
extend T::Sig
|
144
162
|
CMAP_KEYWORDS = {
|
145
163
|
"begincodespacerange" => 1,
|
146
164
|
"endcodespacerange" => 1,
|
@@ -157,33 +175,35 @@ module PDF
|
|
157
175
|
attr_reader :map
|
158
176
|
|
159
177
|
sig { params(data: String).void }
|
160
|
-
def initialize(data)
|
178
|
+
def initialize(data)
|
179
|
+
@map = T.let(T.unsafe(nil), T::Hash[Integer, T::Array[Integer]])
|
180
|
+
end
|
161
181
|
|
162
|
-
sig { params(data: String).void }
|
163
|
-
def process_data(data); end
|
182
|
+
sig { params(data: String, initial_mode: Symbol).void }
|
183
|
+
def process_data(data, initial_mode = :none); end
|
164
184
|
|
165
185
|
sig { returns(Integer) }
|
166
186
|
def size; end
|
167
187
|
|
168
|
-
sig { params(c:
|
188
|
+
sig { params(c: Integer).returns(T::Array[Integer]) }
|
169
189
|
def decode(c); end
|
170
190
|
|
171
|
-
sig { params(instructions:
|
191
|
+
sig { params(instructions: String).returns(PDF::Reader::Parser) }
|
172
192
|
def build_parser(instructions); end
|
173
193
|
|
174
|
-
sig { params(str:
|
194
|
+
sig { params(str: String).returns(T::Array[Integer]) }
|
175
195
|
def str_to_int(str); end
|
176
196
|
|
177
|
-
sig { params(instructions: T
|
197
|
+
sig { params(instructions: T::Array[String]).void }
|
178
198
|
def process_bfchar_instructions(instructions); end
|
179
199
|
|
180
|
-
sig { params(instructions: T.
|
200
|
+
sig { params(instructions: T::Array[T.any(T::Array[String], String)]).void }
|
181
201
|
def process_bfrange_instructions(instructions); end
|
182
202
|
|
183
|
-
sig { params(start_code:
|
203
|
+
sig { params(start_code: String, end_code: String, dst: String).void }
|
184
204
|
def bfrange_type_one(start_code, end_code, dst); end
|
185
205
|
|
186
|
-
sig { params(start_code:
|
206
|
+
sig { params(start_code: String, end_code: String, dst: T::Array[String]).void }
|
187
207
|
def bfrange_type_two(start_code, end_code, dst); end
|
188
208
|
end
|
189
209
|
|
@@ -204,13 +224,13 @@ module PDF
|
|
204
224
|
sig { returns(T.untyped) }
|
205
225
|
def differences; end
|
206
226
|
|
207
|
-
sig { params(str:
|
227
|
+
sig { params(str: String).returns(String) }
|
208
228
|
def to_utf8(str); end
|
209
229
|
|
210
|
-
sig { params(glyph_code:
|
230
|
+
sig { params(glyph_code: Integer).returns(String) }
|
211
231
|
def int_to_utf8_string(glyph_code); end
|
212
232
|
|
213
|
-
sig { params(glyph_code:
|
233
|
+
sig { params(glyph_code: Integer).returns(T::Array[Symbol]) }
|
214
234
|
def int_to_name(glyph_code); end
|
215
235
|
|
216
236
|
sig { returns(T.untyped) }
|
@@ -254,8 +274,14 @@ module PDF
|
|
254
274
|
sig { params(object: Object, name: String, klass: Module).void }
|
255
275
|
def self.validate_type(object, name, klass); end
|
256
276
|
|
277
|
+
sig { params(object: Object, name: String, klass: Module).void }
|
278
|
+
def self.validate_type_as_malformed(object, name, klass); end
|
279
|
+
|
257
280
|
sig { params(object: Object, name: String).void }
|
258
281
|
def self.validate_not_nil(object, name); end
|
282
|
+
|
283
|
+
sig { params(object: Object, name: String).void }
|
284
|
+
def self.validate_not_nil_as_malformed(object, name); end
|
259
285
|
end
|
260
286
|
|
261
287
|
class MalformedPDFError < RuntimeError
|
@@ -390,7 +416,7 @@ module PDF
|
|
390
416
|
sig { returns(T.untyped) }
|
391
417
|
attr_reader :font_flags
|
392
418
|
|
393
|
-
sig { params(ohash:
|
419
|
+
sig { params(ohash: PDF::Reader::ObjectHash, fd_hash: T::Hash[T.untyped, T.untyped]).void }
|
394
420
|
def initialize(ohash, fd_hash); end
|
395
421
|
|
396
422
|
sig { params(char_code: T.untyped).returns(T.untyped) }
|
@@ -454,6 +480,38 @@ module PDF
|
|
454
480
|
def load_adobe_glyph_mapping; end
|
455
481
|
end
|
456
482
|
|
483
|
+
class KeyBuilderV5
|
484
|
+
sig { params(opts: T::Hash[Symbol, String]).void }
|
485
|
+
def initialize(opts = {})
|
486
|
+
@key_length = T.let(T.unsafe(nil), Integer)
|
487
|
+
@owner_key = T.let(T.unsafe(nil), String)
|
488
|
+
@user_key = T.let(T.unsafe(nil), String)
|
489
|
+
@owner_encryption_key = T.let(T.unsafe(nil), String)
|
490
|
+
@user_encryption_key = T.let(T.unsafe(nil), String)
|
491
|
+
end
|
492
|
+
|
493
|
+
sig { params(pass: String).returns(String) }
|
494
|
+
def key(pass); end
|
495
|
+
|
496
|
+
sig { params(password: T.untyped).returns(T.untyped) }
|
497
|
+
def auth_owner_pass(password); end
|
498
|
+
|
499
|
+
sig { params(password: T.untyped).returns(T.untyped) }
|
500
|
+
def auth_user_pass(password); end
|
501
|
+
|
502
|
+
sig { params(password: String).returns(T.nilable(String)) }
|
503
|
+
def auth_owner_pass_r6(password); end
|
504
|
+
|
505
|
+
sig { params(password: String).returns(T.nilable(String)) }
|
506
|
+
def auth_user_pass_r6(password); end
|
507
|
+
|
508
|
+
sig { params(password: String, salt: String, user_key: String).returns(String)}
|
509
|
+
def r6_digest(password, salt, user_key = ''); end
|
510
|
+
|
511
|
+
sig { params(str: String).returns(Integer)}
|
512
|
+
def unpack_128bit_bigendian_int(str); end
|
513
|
+
end
|
514
|
+
|
457
515
|
class LZW
|
458
516
|
CODE_EOD = 257
|
459
517
|
CODE_CLEAR_TABLE = 256
|
@@ -491,9 +549,6 @@ module PDF
|
|
491
549
|
end
|
492
550
|
|
493
551
|
class NullSecurityHandler
|
494
|
-
sig { params(encrypt: T.untyped).returns(T.untyped) }
|
495
|
-
def self.supports?(encrypt); end
|
496
|
-
|
497
552
|
sig { params(buf: T.untyped, _ref: T.untyped).returns(T.untyped) }
|
498
553
|
def decrypt(buf, _ref); end
|
499
554
|
end
|
@@ -586,9 +641,45 @@ module PDF
|
|
586
641
|
sig { params(key: T.untyped).returns(T.untyped) }
|
587
642
|
def object(key); end
|
588
643
|
|
644
|
+
sig { params(key: T.untyped).returns(T.nilable(T::Array[T.untyped])) }
|
645
|
+
def deref_array(key); end
|
646
|
+
|
647
|
+
sig { params(key: T.untyped).returns(T.nilable(T::Array[Numeric])) }
|
648
|
+
def deref_array_of_numbers(key); end
|
649
|
+
|
650
|
+
sig { params(key: T.untyped).returns(T.nilable(T:Hash[Symbol, T.untyped])) }
|
651
|
+
def deref_hash(key); end
|
652
|
+
|
653
|
+
sig { params(key: T.untyped).returns(T.nilable(Symbol)) }
|
654
|
+
def deref_name(key); end
|
655
|
+
|
656
|
+
sig { params(key: T.untyped).returns(T.any(Symbol, T::Array[T.untyped], NilClass)) }
|
657
|
+
def deref_name_or_array(key); end
|
658
|
+
|
659
|
+
sig { params(key: T.untyped).returns(T.nilable(Integer)) }
|
660
|
+
def deref_integer(key); end
|
661
|
+
|
662
|
+
sig { params(key: T.untyped).returns(T.nilable(Numeric)) }
|
663
|
+
def deref_number(key); end
|
664
|
+
|
665
|
+
sig { params(key: T.untyped).returns(T.nilable(PDF::Reader::Stream)) }
|
666
|
+
def deref_stream(key); end
|
667
|
+
|
668
|
+
sig { params(key: T.untyped).returns(T.nilable(String)) }
|
669
|
+
def deref_string(key); end
|
670
|
+
|
671
|
+
sig { params(key: T.untyped).returns(T.any(PDF::Reader::Stream, T::Array[T.untyped], NilClass)) }
|
672
|
+
def deref_stream_or_array(key); end
|
673
|
+
|
589
674
|
sig { params(key: T.untyped).returns(T.untyped) }
|
590
675
|
def deref!(key); end
|
591
676
|
|
677
|
+
sig { params(key: T.untyped).returns(T::Array[T.untyped]) }
|
678
|
+
def deref_array!(key); end
|
679
|
+
|
680
|
+
sig { params(key: T.untyped).returns(T::Hash[Symbol, T.untyped]) }
|
681
|
+
def deref_hash!(key); end
|
682
|
+
|
592
683
|
sig { params(key: T.untyped, local_default: T.untyped).returns(T.untyped) }
|
593
684
|
def fetch(key, local_default = nil); end
|
594
685
|
|
@@ -601,22 +692,22 @@ module PDF
|
|
601
692
|
sig { params(block: T.untyped).returns(T.untyped) }
|
602
693
|
def each_value(&block); end
|
603
694
|
|
604
|
-
sig { returns(
|
695
|
+
sig { returns(Integer) }
|
605
696
|
def size; end
|
606
697
|
|
607
|
-
sig { returns(T
|
698
|
+
sig { returns(T::Boolean) }
|
608
699
|
def empty?; end
|
609
700
|
|
610
|
-
sig { params(check_key: T.untyped).returns(T
|
701
|
+
sig { params(check_key: T.untyped).returns(T::Boolean) }
|
611
702
|
def has_key?(check_key); end
|
612
703
|
|
613
|
-
sig { params(value: T.untyped).returns(T
|
704
|
+
sig { params(value: T.untyped).returns(T::Boolean) }
|
614
705
|
def has_value?(value); end
|
615
706
|
|
616
|
-
sig { returns(
|
707
|
+
sig { returns(String) }
|
617
708
|
def to_s; end
|
618
709
|
|
619
|
-
sig { returns(T
|
710
|
+
sig { returns(T::Array[PDF::Reader::Reference]) }
|
620
711
|
def keys; end
|
621
712
|
|
622
713
|
sig { returns(T.untyped) }
|
@@ -628,13 +719,13 @@ module PDF
|
|
628
719
|
sig { returns(T.untyped) }
|
629
720
|
def to_a; end
|
630
721
|
|
631
|
-
sig { returns(T
|
722
|
+
sig { returns(T::Array[PDF::Reader::Reference]) }
|
632
723
|
def page_references; end
|
633
724
|
|
634
|
-
sig { returns(T
|
725
|
+
sig { returns(T::Boolean) }
|
635
726
|
def encrypted?; end
|
636
727
|
|
637
|
-
sig { returns(T
|
728
|
+
sig { returns(T::Boolean) }
|
638
729
|
def sec_handler?; end
|
639
730
|
|
640
731
|
sig { params(key: T.untyped).returns(T.untyped) }
|
@@ -646,13 +737,10 @@ module PDF
|
|
646
737
|
sig { params(key: T.untyped, seen: T.untyped).returns(T.untyped) }
|
647
738
|
def deref_internal!(key, seen); end
|
648
739
|
|
649
|
-
sig { params(opts: T.untyped).returns(T.untyped) }
|
650
|
-
def build_security_handler(opts = {}); end
|
651
|
-
|
652
740
|
sig { params(ref: T.untyped, obj: T.untyped).returns(T.untyped) }
|
653
741
|
def decrypt(ref, obj); end
|
654
742
|
|
655
|
-
sig { params(offset:
|
743
|
+
sig { params(offset: Integer).returns(PDF::Reader::Buffer) }
|
656
744
|
def new_buffer(offset = 0); end
|
657
745
|
|
658
746
|
sig { returns(T.untyped) }
|
@@ -661,13 +749,13 @@ module PDF
|
|
661
749
|
sig { returns(T.untyped) }
|
662
750
|
def object_streams; end
|
663
751
|
|
664
|
-
sig { params(
|
665
|
-
def get_page_objects(
|
752
|
+
sig { params(obj: T::Hash[T.untyped, T.untyped]).returns(T::Array[T::Hash[T.untyped, T.untyped]]) }
|
753
|
+
def get_page_objects(obj); end
|
666
754
|
|
667
|
-
sig { returns(
|
755
|
+
sig { returns(Float) }
|
668
756
|
def read_version; end
|
669
757
|
|
670
|
-
sig { params(input: T.untyped).returns(
|
758
|
+
sig { params(input: T.untyped).returns(IO) }
|
671
759
|
def extract_io_from(input); end
|
672
760
|
|
673
761
|
sig { params(input: T.untyped).returns(T.untyped) }
|
@@ -695,7 +783,6 @@ module PDF
|
|
695
783
|
end
|
696
784
|
|
697
785
|
class OverlappingRunsFilter
|
698
|
-
extend T::Sig
|
699
786
|
OVERLAPPING_THRESHOLD = 0.5
|
700
787
|
|
701
788
|
sig { params(runs: T::Array[PDF::Reader::TextRun]).returns(T::Array[PDF::Reader::TextRun]) }
|
@@ -706,8 +793,6 @@ module PDF
|
|
706
793
|
end
|
707
794
|
|
708
795
|
class EventPoint
|
709
|
-
extend T::Sig
|
710
|
-
|
711
796
|
sig { returns(Numeric) }
|
712
797
|
attr_reader :x
|
713
798
|
|
@@ -781,7 +866,7 @@ module PDF
|
|
781
866
|
sig { returns(T::Hash[Symbol, T.untyped]) }
|
782
867
|
def root; end
|
783
868
|
|
784
|
-
sig { returns(
|
869
|
+
sig { returns(PDF::Reader::Resources) }
|
785
870
|
def resources; end
|
786
871
|
|
787
872
|
sig { params(receivers: T.untyped, instructions: T.untyped).returns(T.untyped) }
|
@@ -796,12 +881,11 @@ module PDF
|
|
796
881
|
sig { params(origin: T.untyped).returns(T.untyped) }
|
797
882
|
def ancestors(origin = @page_object[:Parent]); end
|
798
883
|
|
799
|
-
sig { params(obj: T.untyped).returns(T.untyped) }
|
884
|
+
sig { params(obj: T::Hash[T.untyped, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
|
800
885
|
def select_inheritable(obj); end
|
801
886
|
end
|
802
887
|
|
803
888
|
class PageLayout
|
804
|
-
extend T::Sig
|
805
889
|
DEFAULT_FONT_SIZE = 12
|
806
890
|
|
807
891
|
sig { params(runs: T::Array[PDF::Reader::TextRun], mediabox: T.any(T::Array[Numeric], PDF::Reader::Rectangle)).void }
|
@@ -1000,25 +1084,25 @@ module PDF
|
|
1000
1084
|
sig { returns(T.untyped) }
|
1001
1085
|
def content; end
|
1002
1086
|
|
1003
|
-
sig { params(string:
|
1087
|
+
sig { params(string: String).void }
|
1004
1088
|
def show_text(string); end
|
1005
1089
|
|
1006
|
-
sig { params(params: T.untyped).
|
1090
|
+
sig { params(params: T::Array[T.untyped]).void }
|
1007
1091
|
def show_text_with_positioning(params); end
|
1008
1092
|
|
1009
|
-
sig { params(str:
|
1093
|
+
sig { params(str: String).void }
|
1010
1094
|
def move_to_next_line_and_show_text(str); end
|
1011
1095
|
|
1012
1096
|
sig { params(opts: T::Hash[Symbol, T.untyped]).returns(T::Array[PDF::Reader::TextRun]) }
|
1013
1097
|
def runs(opts = {}); end
|
1014
1098
|
|
1015
|
-
sig { params(aw:
|
1099
|
+
sig { params(aw: Numeric, ac: Numeric, string: String).void }
|
1016
1100
|
def set_spacing_next_line_show_text(aw, ac, string); end
|
1017
1101
|
|
1018
1102
|
sig { params(label: T.untyped).returns(T.untyped) }
|
1019
1103
|
def invoke_xobject(label); end
|
1020
1104
|
|
1021
|
-
sig { params(string:
|
1105
|
+
sig { params(string: String).void }
|
1022
1106
|
def internal_show_text(string); end
|
1023
1107
|
|
1024
1108
|
sig { params(x: T.untyped, y: T.untyped).returns(T.untyped) }
|
@@ -1103,6 +1187,48 @@ module PDF
|
|
1103
1187
|
}
|
1104
1188
|
end
|
1105
1189
|
|
1190
|
+
class Parser
|
1191
|
+
sig { params(buffer: PDF::Reader::Buffer, objects: T.nilable(PDF::Reader::ObjectHash)).void }
|
1192
|
+
def initialize(buffer, objects=nil); end
|
1193
|
+
|
1194
|
+
sig {
|
1195
|
+
params(
|
1196
|
+
operators: T::Hash[T.any(String, PDF::Reader::Token), Symbol]
|
1197
|
+
).returns(
|
1198
|
+
T.any(PDF::Reader::Reference, PDF::Reader::Token, Numeric, String, Symbol, T::Array[T.untyped], T::Hash[T.untyped, T.untyped], NilClass)
|
1199
|
+
)
|
1200
|
+
}
|
1201
|
+
def parse_token(operators={}); end
|
1202
|
+
|
1203
|
+
sig {
|
1204
|
+
params(
|
1205
|
+
id: Integer,
|
1206
|
+
gen: Integer
|
1207
|
+
).returns(
|
1208
|
+
T.any(PDF::Reader::Reference, PDF::Reader::Token, PDF::Reader::Stream, Numeric, String, Symbol, T::Array[T.untyped], T::Hash[T.untyped, T.untyped], NilClass)
|
1209
|
+
)
|
1210
|
+
}
|
1211
|
+
def object(id, gen); end
|
1212
|
+
|
1213
|
+
sig { returns(T::Hash[Symbol, T.untyped]) }
|
1214
|
+
def dictionary; end
|
1215
|
+
|
1216
|
+
sig { returns(Symbol) }
|
1217
|
+
def pdf_name; end
|
1218
|
+
|
1219
|
+
sig { returns(T::Array[T.untyped]) }
|
1220
|
+
def array; end
|
1221
|
+
|
1222
|
+
sig { returns(String) }
|
1223
|
+
def hex_string; end
|
1224
|
+
|
1225
|
+
sig { returns(String) }
|
1226
|
+
def string; end
|
1227
|
+
|
1228
|
+
sig { params(dict: T::Hash[Symbol, T.untyped]).returns(PDF::Reader::Stream) }
|
1229
|
+
def stream(dict); end
|
1230
|
+
end
|
1231
|
+
|
1106
1232
|
class Point
|
1107
1233
|
sig do
|
1108
1234
|
params(
|
@@ -1110,7 +1236,10 @@ module PDF
|
|
1110
1236
|
y: Numeric,
|
1111
1237
|
).void
|
1112
1238
|
end
|
1113
|
-
def initialize(x, y)
|
1239
|
+
def initialize(x, y)
|
1240
|
+
@x = T.let(T.unsafe(nil), Numeric)
|
1241
|
+
@y = T.let(T.unsafe(nil), Numeric)
|
1242
|
+
end
|
1114
1243
|
|
1115
1244
|
sig { returns(Numeric) }
|
1116
1245
|
def x; end
|
@@ -1137,7 +1266,18 @@ module PDF
|
|
1137
1266
|
def method_missing(methodname, *args); end
|
1138
1267
|
end
|
1139
1268
|
|
1269
|
+
class Rc4SecurityHandler
|
1270
|
+
sig { params(key: String).void }
|
1271
|
+
def initialize(key)
|
1272
|
+
@encrypt_key = T.let(T.unsafe(nil), String)
|
1273
|
+
end
|
1274
|
+
|
1275
|
+
sig { params(buf: T.untyped, ref: T.untyped).returns(T.untyped) }
|
1276
|
+
def decrypt(buf, ref); end
|
1277
|
+
end
|
1278
|
+
|
1140
1279
|
class Rectangle
|
1280
|
+
|
1141
1281
|
sig { params(arr: T::Array[Numeric]).returns(PDF::Reader::Rectangle) }
|
1142
1282
|
def self.from_array(arr); end
|
1143
1283
|
|
@@ -1149,7 +1289,13 @@ module PDF
|
|
1149
1289
|
y2: Numeric
|
1150
1290
|
).void
|
1151
1291
|
end
|
1152
|
-
|
1292
|
+
|
1293
|
+
def initialize(x1, y1, x2, y2)
|
1294
|
+
@bottom_left = T.let(T.unsafe(nil), PDF::Reader::Point)
|
1295
|
+
@bottom_right = T.let(T.unsafe(nil), PDF::Reader::Point)
|
1296
|
+
@top_left = T.let(T.unsafe(nil), PDF::Reader::Point)
|
1297
|
+
@top_right = T.let(T.unsafe(nil), PDF::Reader::Point)
|
1298
|
+
end
|
1153
1299
|
|
1154
1300
|
sig { returns(PDF::Reader::Point) }
|
1155
1301
|
def bottom_left; end
|
@@ -1174,6 +1320,15 @@ module PDF
|
|
1174
1320
|
|
1175
1321
|
sig { params(degrees: Integer).void }
|
1176
1322
|
def apply_rotation(degrees); end
|
1323
|
+
|
1324
|
+
sig { params(point: PDF::Reader::Point).void }
|
1325
|
+
def contains?(point); end
|
1326
|
+
|
1327
|
+
sig { params(other: PDF::Reader::Rectangle).void }
|
1328
|
+
def ==(other); end
|
1329
|
+
|
1330
|
+
sig { params(x1: Numeric, y1: Numeric, x2: Numeric, y2: Numeric).void }
|
1331
|
+
def set_corners(x1, y1, x2, y2); end
|
1177
1332
|
end
|
1178
1333
|
|
1179
1334
|
class Reference
|
@@ -1237,7 +1392,7 @@ module PDF
|
|
1237
1392
|
sig { returns(T.untyped) }
|
1238
1393
|
def color_spaces; end
|
1239
1394
|
|
1240
|
-
sig { returns(T.untyped) }
|
1395
|
+
sig { returns(T::Hash[T.untyped, T.untyped]) }
|
1241
1396
|
def fonts; end
|
1242
1397
|
|
1243
1398
|
sig { returns(T.untyped) }
|
@@ -1259,50 +1414,34 @@ module PDF
|
|
1259
1414
|
def xobjects; end
|
1260
1415
|
end
|
1261
1416
|
|
1262
|
-
class
|
1263
|
-
|
1264
|
-
|
1265
|
-
0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80,
|
1266
|
-
0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a ]
|
1267
|
-
|
1268
|
-
sig { returns(T.untyped) }
|
1269
|
-
attr_reader :key_length
|
1270
|
-
|
1271
|
-
sig { returns(T.untyped) }
|
1272
|
-
attr_reader :revision
|
1273
|
-
|
1274
|
-
sig { returns(T.untyped) }
|
1275
|
-
attr_reader :encrypt_key
|
1276
|
-
|
1277
|
-
sig { returns(T.untyped) }
|
1278
|
-
attr_reader :owner_key
|
1279
|
-
|
1280
|
-
sig { returns(T.untyped) }
|
1281
|
-
attr_reader :user_key
|
1282
|
-
|
1283
|
-
sig { returns(T.untyped) }
|
1284
|
-
attr_reader :permissions
|
1417
|
+
class SecurityHandlerFactory
|
1418
|
+
sig { params(encrypt: T.untyped, doc_id: T.untyped, password: T.untyped).returns(T.untyped) }
|
1419
|
+
def self.build(encrypt, doc_id, password); end
|
1285
1420
|
|
1286
|
-
sig { returns(T.untyped) }
|
1287
|
-
|
1421
|
+
sig { params(encrypt: T.untyped, doc_id: T.untyped, password: T.untyped).returns(T.untyped) }
|
1422
|
+
def self.build_standard_handler(encrypt, doc_id, password); end
|
1288
1423
|
|
1289
|
-
sig { returns(T.untyped) }
|
1290
|
-
|
1424
|
+
sig { params(encrypt: T.untyped, doc_id: T.untyped, password: T.untyped).returns(T.untyped) }
|
1425
|
+
def self.build_v5_handler(encrypt, doc_id, password); end
|
1291
1426
|
|
1292
|
-
sig { params(
|
1293
|
-
def
|
1427
|
+
sig { params(encrypt: T.untyped).returns(T.untyped) }
|
1428
|
+
def self.standard?(encrypt); end
|
1294
1429
|
|
1295
1430
|
sig { params(encrypt: T.untyped).returns(T.untyped) }
|
1296
|
-
def self.
|
1431
|
+
def self.standard_v5?(encrypt); end
|
1432
|
+
end
|
1297
1433
|
|
1298
|
-
|
1299
|
-
|
1434
|
+
class StandardKeyBuilder
|
1435
|
+
PassPadBytes = [ 0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41,
|
1436
|
+
0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08,
|
1437
|
+
0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80,
|
1438
|
+
0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a ]
|
1300
1439
|
|
1301
|
-
sig { params(
|
1302
|
-
def
|
1440
|
+
sig { params(opts: T::Hash[Symbol, T.untyped]).void }
|
1441
|
+
def initialize(opts = {}); end
|
1303
1442
|
|
1304
|
-
sig { params(
|
1305
|
-
def
|
1443
|
+
sig { params(pass: String).returns(String) }
|
1444
|
+
def key(pass); end
|
1306
1445
|
|
1307
1446
|
sig { params(p: T.untyped).returns(T.untyped) }
|
1308
1447
|
def pad_pass(p = ""); end
|
@@ -1318,48 +1457,23 @@ module PDF
|
|
1318
1457
|
|
1319
1458
|
sig { params(user_pass: T.untyped).returns(T.untyped) }
|
1320
1459
|
def make_file_key(user_pass); end
|
1321
|
-
|
1322
|
-
sig { params(pass: T.untyped).returns(T.untyped) }
|
1323
|
-
def build_standard_key(pass); end
|
1324
|
-
end
|
1325
|
-
|
1326
|
-
class StandardSecurityHandlerV5
|
1327
|
-
sig { returns(T.untyped) }
|
1328
|
-
attr_reader :key_length
|
1329
|
-
|
1330
|
-
sig { returns(T.untyped) }
|
1331
|
-
attr_reader :encrypt_key
|
1332
|
-
|
1333
|
-
sig { params(opts: T.untyped).void }
|
1334
|
-
def initialize(opts = {}); end
|
1335
|
-
|
1336
|
-
sig { params(encrypt: T.untyped).returns(T.untyped) }
|
1337
|
-
def self.supports?(encrypt); end
|
1338
|
-
|
1339
|
-
sig { params(buf: T.untyped, ref: T.untyped).returns(T.untyped) }
|
1340
|
-
def decrypt(buf, ref); end
|
1341
|
-
|
1342
|
-
sig { params(password: T.untyped).returns(T.untyped) }
|
1343
|
-
def auth_owner_pass(password); end
|
1344
|
-
|
1345
|
-
sig { params(password: T.untyped).returns(T.untyped) }
|
1346
|
-
def auth_user_pass(password); end
|
1347
|
-
|
1348
|
-
sig { params(pass: T.untyped).returns(T.untyped) }
|
1349
|
-
def build_standard_key(pass); end
|
1350
1460
|
end
|
1351
1461
|
|
1352
1462
|
class Stream
|
1353
|
-
sig { returns(T.untyped) }
|
1463
|
+
sig { returns(T::Hash[Symbol, T.untyped]) }
|
1354
1464
|
attr_accessor :hash
|
1355
1465
|
|
1356
|
-
sig { returns(
|
1466
|
+
sig { returns(String) }
|
1357
1467
|
attr_accessor :data
|
1358
1468
|
|
1359
|
-
sig { params(hash: T.untyped, data:
|
1360
|
-
def initialize(hash, data)
|
1469
|
+
sig { params(hash: T::Hash[Symbol, T.untyped], data: String).void }
|
1470
|
+
def initialize(hash, data)
|
1471
|
+
@hash = T.let(T.unsafe(nil), T::Hash[Symbol, T.untyped])
|
1472
|
+
@data = T.let(T.unsafe(nil), String)
|
1473
|
+
@udata = T.let(T.unsafe(nil), T.nilable(String))
|
1474
|
+
end
|
1361
1475
|
|
1362
|
-
sig { returns(
|
1476
|
+
sig { returns(String) }
|
1363
1477
|
def unfiltered_data; end
|
1364
1478
|
end
|
1365
1479
|
|
@@ -1376,7 +1490,6 @@ module PDF
|
|
1376
1490
|
|
1377
1491
|
class TextRun
|
1378
1492
|
include Comparable
|
1379
|
-
extend T::Sig
|
1380
1493
|
|
1381
1494
|
sig { returns(T.untyped) }
|
1382
1495
|
attr_reader :x
|
@@ -1559,6 +1672,109 @@ module PDF
|
|
1559
1672
|
def faster_multiply!(a2, b2, c2, d2, e2, f2); end
|
1560
1673
|
end
|
1561
1674
|
|
1675
|
+
class TypeCheck
|
1676
|
+
|
1677
|
+
sig { params(obj: T.untyped).returns(Numeric) }
|
1678
|
+
def self.cast_to_numeric!(obj); end
|
1679
|
+
|
1680
|
+
sig { params(string: T.untyped).returns(String) }
|
1681
|
+
def self.cast_to_string!(string); end
|
1682
|
+
|
1683
|
+
sig { params(obj: T.untyped).returns(T.nilable(Symbol)) }
|
1684
|
+
def self.cast_to_symbol(obj); end
|
1685
|
+
end
|
1686
|
+
|
1687
|
+
class ValidatingReceiver
|
1688
|
+
sig { params(wrapped: T.untyped).void }
|
1689
|
+
def initialize(wrapped)
|
1690
|
+
@wrapped = T.let(T.unsafe(nil), T.untyped)
|
1691
|
+
end
|
1692
|
+
|
1693
|
+
sig { params(page: PDF::Reader::Page).void }
|
1694
|
+
def page=(page); end
|
1695
|
+
|
1696
|
+
sig { params(args: T.untyped).void }
|
1697
|
+
def save_graphics_state(*args); end
|
1698
|
+
|
1699
|
+
sig { params(args: T.untyped).void }
|
1700
|
+
def restore_graphics_state(*args); end
|
1701
|
+
|
1702
|
+
sig { params(args: T.untyped).void }
|
1703
|
+
def concatenate_matrix(*args); end
|
1704
|
+
|
1705
|
+
sig { params(args: T.untyped).void }
|
1706
|
+
def begin_text_object(*args); end
|
1707
|
+
|
1708
|
+
sig { params(args: T.untyped).void }
|
1709
|
+
def end_text_object(*args); end
|
1710
|
+
|
1711
|
+
sig { params(args: T.untyped).void }
|
1712
|
+
def set_character_spacing(*args); end
|
1713
|
+
|
1714
|
+
sig { params(args: T.untyped).void }
|
1715
|
+
def set_horizontal_text_scaling(*args); end
|
1716
|
+
|
1717
|
+
sig { params(args: T.untyped).void }
|
1718
|
+
def set_text_font_and_size(*args); end
|
1719
|
+
|
1720
|
+
sig { params(args: T.untyped).void }
|
1721
|
+
def set_text_leading(*args); end
|
1722
|
+
|
1723
|
+
sig { params(args: T.untyped).void }
|
1724
|
+
def set_text_rendering_mode(*args); end
|
1725
|
+
|
1726
|
+
sig { params(args: T.untyped).void }
|
1727
|
+
def set_text_rise(*args); end
|
1728
|
+
|
1729
|
+
sig { params(args: T.untyped).void }
|
1730
|
+
def set_word_spacing(*args); end
|
1731
|
+
|
1732
|
+
sig { params(args: T.untyped).void }
|
1733
|
+
def move_text_position(*args); end
|
1734
|
+
|
1735
|
+
sig { params(args: T.untyped).void }
|
1736
|
+
def move_text_position_and_set_leading(*args); end
|
1737
|
+
|
1738
|
+
sig { params(args: T.untyped).void }
|
1739
|
+
def set_text_matrix_and_text_line_matrix(*args); end
|
1740
|
+
|
1741
|
+
sig { params(args: T.untyped).void }
|
1742
|
+
def move_to_start_of_next_line(*args); end
|
1743
|
+
|
1744
|
+
sig { params(args: T.untyped).void }
|
1745
|
+
def show_text(*args); end
|
1746
|
+
|
1747
|
+
sig { params(args: T.untyped).void }
|
1748
|
+
def show_text_with_positioning(*args); end
|
1749
|
+
|
1750
|
+
sig { params(args: T.untyped).void }
|
1751
|
+
def move_to_next_line_and_show_text(*args); end
|
1752
|
+
|
1753
|
+
sig { params(args: T.untyped).void }
|
1754
|
+
def set_spacing_next_line_show_text(*args); end
|
1755
|
+
|
1756
|
+
sig { params(args: T.untyped).void }
|
1757
|
+
def invoke_xobject(*args); end
|
1758
|
+
|
1759
|
+
sig { params(args: T.untyped).void }
|
1760
|
+
def begin_inline_image(*args); end
|
1761
|
+
|
1762
|
+
sig { params(args: T.untyped).void }
|
1763
|
+
def begin_inline_image_data(*args); end
|
1764
|
+
|
1765
|
+
sig { params(args: T.untyped).void }
|
1766
|
+
def end_inline_image(*args); end
|
1767
|
+
|
1768
|
+
sig { params(meth: T.untyped).returns(T::Boolean) }
|
1769
|
+
def respond_to?(meth); end
|
1770
|
+
|
1771
|
+
sig { params(methodname: Symbol, args: T.untyped).void }
|
1772
|
+
def method_missing(methodname, *args); end
|
1773
|
+
|
1774
|
+
sig { params(methodname: T.untyped, args: T.untyped).void }
|
1775
|
+
def call_wrapped(methodname, *args); end
|
1776
|
+
end
|
1777
|
+
|
1562
1778
|
class UnimplementedSecurityHandler
|
1563
1779
|
sig { params(encrypt: T.untyped).returns(T.untyped) }
|
1564
1780
|
def self.supports?(encrypt); end
|
@@ -1608,40 +1824,36 @@ module PDF
|
|
1608
1824
|
end
|
1609
1825
|
|
1610
1826
|
class ZeroWidthRunsFilter
|
1611
|
-
extend T::Sig
|
1612
|
-
|
1613
1827
|
sig { params(runs: T::Array[PDF::Reader::TextRun]).returns(T::Array[PDF::Reader::TextRun]) }
|
1614
1828
|
def self.exclude_zero_width_runs(runs); end
|
1615
1829
|
end
|
1616
1830
|
|
1617
1831
|
module Filter
|
1618
|
-
sig { params(name:
|
1832
|
+
sig { params(name: Symbol, options: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
1619
1833
|
def self.with(name, options = {}); end
|
1620
1834
|
|
1621
1835
|
class Ascii85
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1836
|
+
sig { params(options: T::Hash[T.untyped, T.untyped]).void }
|
1837
|
+
def initialize(options = {})
|
1838
|
+
@options = T.let(T.unsafe(nil), T::Hash[T.untyped, T.untyped])
|
1839
|
+
end
|
1626
1840
|
|
1627
1841
|
sig { params(data: String).returns(String) }
|
1628
1842
|
def filter(data); end
|
1629
1843
|
end
|
1630
1844
|
|
1631
1845
|
class AsciiHex
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1846
|
+
sig { params(options: T::Hash[T.untyped, T.untyped]).void }
|
1847
|
+
def initialize(options = {})
|
1848
|
+
@options = T.let(T.unsafe(nil), T::Hash[T.untyped, T.untyped])
|
1849
|
+
end
|
1636
1850
|
|
1637
1851
|
sig { params(data: String).returns(String) }
|
1638
1852
|
def filter(data); end
|
1639
1853
|
end
|
1640
1854
|
|
1641
1855
|
class Depredict
|
1642
|
-
|
1643
|
-
|
1644
|
-
sig { params(options: T.untyped).void }
|
1856
|
+
sig { params(options: T::Hash[T.untyped, T.untyped]).void }
|
1645
1857
|
def initialize(options = {}); end
|
1646
1858
|
|
1647
1859
|
sig { params(data: String).returns(String) }
|
@@ -1655,12 +1867,13 @@ module PDF
|
|
1655
1867
|
end
|
1656
1868
|
|
1657
1869
|
class Flate
|
1658
|
-
extend T::Sig
|
1659
1870
|
ZLIB_AUTO_DETECT_ZLIB_OR_GZIP = 47
|
1660
1871
|
ZLIB_RAW_DEFLATE = -15
|
1661
1872
|
|
1662
|
-
sig { params(options: T.untyped).void }
|
1663
|
-
def initialize(options = {})
|
1873
|
+
sig { params(options: T::Hash[T.untyped, T.untyped]).void }
|
1874
|
+
def initialize(options = {})
|
1875
|
+
@options = T.let(T.unsafe(nil), T::Hash[T.untyped, T.untyped])
|
1876
|
+
end
|
1664
1877
|
|
1665
1878
|
sig { params(data: String).returns(String) }
|
1666
1879
|
def filter(data); end
|
@@ -1670,28 +1883,30 @@ module PDF
|
|
1670
1883
|
end
|
1671
1884
|
|
1672
1885
|
class Lzw
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1886
|
+
sig { params(options: T::Hash[T.untyped, T.untyped]).void }
|
1887
|
+
def initialize(options = {})
|
1888
|
+
@options = T.let(T.unsafe(nil), T::Hash[T.untyped, T.untyped])
|
1889
|
+
end
|
1677
1890
|
|
1678
1891
|
sig { params(data: String).returns(String) }
|
1679
1892
|
def filter(data); end
|
1680
1893
|
end
|
1681
1894
|
|
1682
1895
|
class Null
|
1683
|
-
sig { params(options: T.untyped).void }
|
1684
|
-
def initialize(options = {})
|
1896
|
+
sig { params(options: T::Hash[T.untyped, T.untyped]).void }
|
1897
|
+
def initialize(options = {})
|
1898
|
+
@options = T.let(T.unsafe(nil), T::Hash[T.untyped, T.untyped])
|
1899
|
+
end
|
1685
1900
|
|
1686
1901
|
sig { params(data: T.untyped).returns(T.untyped) }
|
1687
1902
|
def filter(data); end
|
1688
1903
|
end
|
1689
1904
|
|
1690
1905
|
class RunLength
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1906
|
+
sig { params(options: T::Hash[T.untyped, T.untyped]).void }
|
1907
|
+
def initialize(options = {})
|
1908
|
+
@options = T.let(T.unsafe(nil), T::Hash[T.untyped, T.untyped])
|
1909
|
+
end
|
1695
1910
|
|
1696
1911
|
sig { params(data: String).returns(String) }
|
1697
1912
|
def filter(data); end
|