pdf-reader 2.10.0 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/Rakefile +1 -1
- data/lib/pdf/reader/buffer.rb +1 -1
- data/lib/pdf/reader/cid_widths.rb +3 -1
- data/lib/pdf/reader/cmap.rb +1 -1
- data/lib/pdf/reader/encoding.rb +4 -4
- data/lib/pdf/reader/filter/depredict.rb +1 -1
- data/lib/pdf/reader/glyph_hash.rb +13 -5
- data/lib/pdf/reader/no_text_filter.rb +14 -0
- data/lib/pdf/reader/object_hash.rb +8 -6
- data/lib/pdf/reader/object_stream.rb +1 -1
- data/lib/pdf/reader/overlapping_runs_filter.rb +1 -1
- data/lib/pdf/reader/page.rb +23 -6
- data/lib/pdf/reader/page_layout.rb +1 -1
- data/lib/pdf/reader/page_text_receiver.rb +2 -0
- data/lib/pdf/reader/pages_strategy.rb +1 -1
- data/lib/pdf/reader/reference.rb +3 -2
- data/lib/pdf/reader/resources.rb +1 -1
- data/lib/pdf/reader/synchronized_cache.rb +1 -1
- data/lib/pdf/reader/text_run.rb +5 -2
- data/lib/pdf/reader/transformation_matrix.rb +8 -8
- data/lib/pdf/reader/width_calculator/built_in.rb +1 -1
- data/lib/pdf/reader/xref.rb +3 -3
- data/lib/pdf/reader.rb +5 -10
- data/rbi/pdf-reader.rbi +276 -253
- metadata +6 -5
data/rbi/pdf-reader.rbi
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
# typed: strong
|
2
2
|
module PDF
|
3
3
|
class Reader
|
4
|
-
sig { returns(
|
4
|
+
sig { returns(PDF::Reader::ObjectHash) }
|
5
5
|
attr_reader :objects
|
6
6
|
|
7
|
-
sig { params(input: T.any(String, IO), opts: T::Hash[T.untyped, T.untyped]).void }
|
8
|
-
def initialize(input, opts = {})
|
7
|
+
sig { params(input: T.any(String, Tempfile, IO), opts: T::Hash[T.untyped, T.untyped]).void }
|
8
|
+
def initialize(input, opts = {})
|
9
|
+
@cache = T.let(T.unsafe(nil), PDF::Reader::ObjectCache)
|
10
|
+
@objects = T.let(T.unsafe(nil), PDF::Reader::ObjectHash)
|
11
|
+
@page_count = T.let(T.unsafe(nil), T.nilable(Integer))
|
12
|
+
@root = T.let(T.unsafe(nil), T.nilable(T.nilable(T::Hash[Symbol, T.untyped])))
|
13
|
+
end
|
9
14
|
|
10
15
|
sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
|
11
16
|
def info; end
|
12
17
|
|
13
|
-
sig { returns(T.nilable(
|
18
|
+
sig { returns(T.nilable(String)) }
|
14
19
|
def metadata; end
|
15
20
|
|
16
21
|
sig { returns(Integer) }
|
@@ -19,7 +24,7 @@ module PDF
|
|
19
24
|
sig { returns(Float) }
|
20
25
|
def pdf_version; end
|
21
26
|
|
22
|
-
sig { params(input: T.any(String, IO), opts: T::Hash[T.untyped, T.untyped], block: T.proc.params(arg0: PDF::Reader).void).returns(T.untyped) }
|
27
|
+
sig { params(input: T.any(String, Tempfile, IO), opts: T::Hash[T.untyped, T.untyped], block: T.proc.params(arg0: PDF::Reader).void).returns(T.untyped) }
|
23
28
|
def self.open(input, opts = {}, &block); end
|
24
29
|
|
25
30
|
sig { returns(T::Array[PDF::Reader::Page]) }
|
@@ -70,28 +75,29 @@ module PDF
|
|
70
75
|
end
|
71
76
|
|
72
77
|
class Buffer
|
73
|
-
TOKEN_WHITESPACE =
|
74
|
-
TOKEN_DELIMITER =
|
75
|
-
LEFT_PAREN =
|
76
|
-
LESS_THAN =
|
77
|
-
STREAM =
|
78
|
-
ID =
|
79
|
-
FWD_SLASH =
|
80
|
-
NULL_BYTE =
|
81
|
-
CR =
|
82
|
-
LF =
|
83
|
-
CRLF =
|
84
|
-
WHITE_SPACE =
|
85
|
-
TRAILING_BYTECOUNT =
|
78
|
+
TOKEN_WHITESPACE = T.let(T.unsafe(nil), T::Array[Integer])
|
79
|
+
TOKEN_DELIMITER = T.let(T.unsafe(nil), T::Array[Integer])
|
80
|
+
LEFT_PAREN = T.let(T.unsafe(nil), String)
|
81
|
+
LESS_THAN = T.let(T.unsafe(nil), String)
|
82
|
+
STREAM = T.let(T.unsafe(nil), String)
|
83
|
+
ID = T.let(T.unsafe(nil), String)
|
84
|
+
FWD_SLASH = T.let(T.unsafe(nil), String)
|
85
|
+
NULL_BYTE = T.let(T.unsafe(nil), String)
|
86
|
+
CR = T.let(T.unsafe(nil), String)
|
87
|
+
LF = T.let(T.unsafe(nil), String)
|
88
|
+
CRLF = T.let(T.unsafe(nil), String)
|
89
|
+
WHITE_SPACE = T.let(T.unsafe(nil), T::Array[String])
|
90
|
+
TRAILING_BYTECOUNT = T.let(T.unsafe(nil), Integer)
|
91
|
+
DIGITS_ONLY = T.let(T.unsafe(nil), Regexp)
|
86
92
|
|
87
93
|
sig { returns(Integer) }
|
88
94
|
attr_reader :pos
|
89
95
|
|
90
|
-
sig { params(io: T.any(StringIO,
|
96
|
+
sig { params(io: T.any(StringIO, Tempfile, IO), opts: T::Hash[Symbol, T.untyped]).void }
|
91
97
|
def initialize(io, opts = {})
|
92
98
|
@pos = T.let(T.unsafe(nil), Integer)
|
93
99
|
@tokens = T.let(T.unsafe(nil), T::Array[T.any(String, PDF::Reader::Reference)])
|
94
|
-
@io = T.let(T.unsafe(nil), T.any(StringIO,
|
100
|
+
@io = T.let(T.unsafe(nil), T.any(StringIO, Tempfile, IO))
|
95
101
|
@in_content_stream = T.let(T.unsafe(nil), T::Boolean)
|
96
102
|
end
|
97
103
|
|
@@ -161,17 +167,7 @@ module PDF
|
|
161
167
|
end
|
162
168
|
|
163
169
|
class CMap
|
164
|
-
CMAP_KEYWORDS =
|
165
|
-
"begincodespacerange" => 1,
|
166
|
-
"endcodespacerange" => 1,
|
167
|
-
"beginbfchar" => 1,
|
168
|
-
"endbfchar" => 1,
|
169
|
-
"beginbfrange" => 1,
|
170
|
-
"endbfrange" => 1,
|
171
|
-
"begin" => 1,
|
172
|
-
"begincmap" => 1,
|
173
|
-
"def" => 1
|
174
|
-
}
|
170
|
+
CMAP_KEYWORDS = T.let(T.unsafe(nil), T::Hash[String, Symbol])
|
175
171
|
|
176
172
|
sig { returns(T.untyped) }
|
177
173
|
attr_reader :map
|
@@ -210,20 +206,27 @@ module PDF
|
|
210
206
|
end
|
211
207
|
|
212
208
|
class Encoding
|
213
|
-
CONTROL_CHARS = [
|
214
|
-
|
215
|
-
UNKNOWN_CHAR = 0x25AF
|
209
|
+
CONTROL_CHARS = T.let(T.unsafe(nil), T::Array[Integer])
|
210
|
+
UNKNOWN_CHAR = T.let(T.unsafe(nil), Integer)
|
216
211
|
|
217
|
-
sig { returns(
|
212
|
+
sig { returns(String) }
|
218
213
|
attr_reader :unpack
|
219
214
|
|
220
215
|
sig { params(enc: T.untyped).void }
|
221
|
-
def initialize(enc)
|
216
|
+
def initialize(enc)
|
217
|
+
@mapping = T.let(T.unsafe(nil), T::Hash[Integer, Integer])
|
218
|
+
@unpack = T.let(T.unsafe(nil), String)
|
219
|
+
@enc_name = T.let(T.unsafe(nil), Symbol)
|
220
|
+
@string_cache = T.let(T.unsafe(nil), T::Hash[Integer, String])
|
221
|
+
@map_file = T.let(T.unsafe(nil), T.nilable(String))
|
222
|
+
@differences = T.let(T.unsafe(nil), T.nilable(T::Hash[Integer, Integer]))
|
223
|
+
@glyphlist = T.let(T.unsafe(nil), T.nilable(PDF::Reader::GlyphHash))
|
224
|
+
end
|
222
225
|
|
223
|
-
sig { params(diff: T.
|
226
|
+
sig { params(diff: T::Array[T.any(Integer, Symbol)]).returns(T::Hash[Integer, Integer]) }
|
224
227
|
def differences=(diff); end
|
225
228
|
|
226
|
-
sig { returns(T
|
229
|
+
sig { returns(T::Hash[Integer, Integer]) }
|
227
230
|
def differences; end
|
228
231
|
|
229
232
|
sig { params(str: String).returns(String) }
|
@@ -235,31 +238,31 @@ module PDF
|
|
235
238
|
sig { params(glyph_code: Integer).returns(T::Array[Symbol]) }
|
236
239
|
def int_to_name(glyph_code); end
|
237
240
|
|
238
|
-
sig { returns(T
|
241
|
+
sig { returns(T::Hash[Integer, Integer]) }
|
239
242
|
def default_mapping; end
|
240
243
|
|
241
|
-
sig { params(glyph_code:
|
244
|
+
sig { params(glyph_code: Integer).returns(String) }
|
242
245
|
def internal_int_to_utf8_string(glyph_code); end
|
243
246
|
|
244
|
-
sig { returns(T
|
247
|
+
sig { returns(T::Boolean) }
|
245
248
|
def utf8_conversion_impossible?; end
|
246
249
|
|
247
|
-
sig { params(times:
|
250
|
+
sig { params(times: Integer).returns(String) }
|
248
251
|
def little_boxes(times); end
|
249
252
|
|
250
|
-
sig { params(str:
|
253
|
+
sig { params(str: String).returns(String) }
|
251
254
|
def convert_to_utf8(str); end
|
252
255
|
|
253
|
-
sig { params(enc: T.untyped).returns(
|
256
|
+
sig { params(enc: T.untyped).returns(String) }
|
254
257
|
def get_unpack(enc); end
|
255
258
|
|
256
|
-
sig { params(enc: T.untyped).returns(T.
|
259
|
+
sig { params(enc: T.untyped).returns(T.nilable(String)) }
|
257
260
|
def get_mapping_file(enc); end
|
258
261
|
|
259
|
-
sig { returns(
|
262
|
+
sig { returns(PDF::Reader::GlyphHash) }
|
260
263
|
def glyphlist; end
|
261
264
|
|
262
|
-
sig { params(file:
|
265
|
+
sig { params(file: String).void }
|
263
266
|
def load_mapping(file); end
|
264
267
|
end
|
265
268
|
|
@@ -474,16 +477,22 @@ module PDF
|
|
474
477
|
end
|
475
478
|
|
476
479
|
class GlyphHash
|
480
|
+
@@by_name_cache = T.let(T.unsafe(nil), T.nilable(T::Hash[Symbol, Integer]))
|
481
|
+
@@by_codepoint_cache = T.let(T.unsafe(nil), T.nilable(T::Hash[Integer, T::Array[Symbol]]))
|
482
|
+
|
477
483
|
sig { void }
|
478
|
-
def initialize
|
484
|
+
def initialize
|
485
|
+
@by_name = T.let(T.unsafe(nil), T::Hash[Symbol, Integer])
|
486
|
+
@by_codepoint = T.let(T.unsafe(nil), T::Hash[Integer, T::Array[Symbol]])
|
487
|
+
end
|
479
488
|
|
480
|
-
sig { params(name: T.
|
489
|
+
sig { params(name: T.nilable(Symbol)).returns(T.nilable(Integer)) }
|
481
490
|
def name_to_unicode(name); end
|
482
491
|
|
483
|
-
sig { params(codepoint: T.
|
492
|
+
sig { params(codepoint: T.nilable(Integer)).returns(T::Array[Symbol]) }
|
484
493
|
def unicode_to_name(codepoint); end
|
485
494
|
|
486
|
-
sig { returns(T
|
495
|
+
sig { returns([T::Hash[Symbol, Integer], T::Hash[Integer, T::Array[Symbol]]]) }
|
487
496
|
def load_adobe_glyph_mapping; end
|
488
497
|
end
|
489
498
|
|
@@ -633,25 +642,45 @@ module PDF
|
|
633
642
|
sig { returns(T.untyped) }
|
634
643
|
attr_accessor :default
|
635
644
|
|
636
|
-
sig { returns(T.untyped) }
|
645
|
+
sig { returns(T::Hash[Symbol, T.untyped]) }
|
637
646
|
attr_reader :trailer
|
638
647
|
|
639
|
-
sig { returns(
|
648
|
+
sig { returns(Float) }
|
640
649
|
attr_reader :pdf_version
|
641
650
|
|
642
|
-
sig { returns(
|
651
|
+
sig { returns(
|
652
|
+
T.any(
|
653
|
+
PDF::Reader::NullSecurityHandler,
|
654
|
+
PDF::Reader::AesV2SecurityHandler,
|
655
|
+
PDF::Reader::AesV3SecurityHandler,
|
656
|
+
PDF::Reader::Rc4SecurityHandler,
|
657
|
+
)) }
|
643
658
|
attr_reader :sec_handler
|
644
659
|
|
645
|
-
sig { params(input: T.
|
646
|
-
def initialize(input, opts = {})
|
660
|
+
sig { params(input: T.any(IO, Tempfile, StringIO, String), opts: T::Hash[Symbol, T.untyped]).void }
|
661
|
+
def initialize(input, opts = {})
|
662
|
+
@io = T.let(T.unsafe(nil), T.any(IO, Tempfile, StringIO))
|
663
|
+
@xref = T.let(T.unsafe(nil), PDF::Reader::XRef)
|
664
|
+
@pdf_version = T.let(T.unsafe(nil), Float)
|
665
|
+
@trailer = T.let(T.unsafe(nil), T::Hash[Symbol, T.untyped])
|
666
|
+
@cache = T.let(T.unsafe(nil), PDF::Reader::ObjectCache)
|
667
|
+
@sec_handler = T.let(T.unsafe(nil), T.any(
|
668
|
+
PDF::Reader::NullSecurityHandler,
|
669
|
+
PDF::Reader::AesV2SecurityHandler,
|
670
|
+
PDF::Reader::AesV3SecurityHandler,
|
671
|
+
PDF::Reader::Rc4SecurityHandler,
|
672
|
+
))
|
673
|
+
@page_references = T.let(T.unsafe(nil), T.nilable(T::Array[T.any(PDF::Reader::Reference, T::Hash[Symbol, T.untyped])]))
|
674
|
+
@object_streams = T.let(T.unsafe(nil), T.nilable(T::Hash[PDF::Reader::Reference, PDF::Reader::ObjectStream]))
|
675
|
+
end
|
647
676
|
|
648
|
-
sig { params(ref: T.
|
677
|
+
sig { params(ref: T.any(Integer, PDF::Reader::Reference)).returns(T.nilable(Symbol)) }
|
649
678
|
def obj_type(ref); end
|
650
679
|
|
651
|
-
sig { params(ref: T.
|
680
|
+
sig { params(ref: T.any(Integer, PDF::Reader::Reference)).returns(T::Boolean) }
|
652
681
|
def stream?(ref); end
|
653
682
|
|
654
|
-
sig { params(key: T.
|
683
|
+
sig { params(key: T.any(Integer, PDF::Reader::Reference)).returns(T.untyped) }
|
655
684
|
def [](key); end
|
656
685
|
|
657
686
|
sig { params(key: T.untyped).returns(T.untyped) }
|
@@ -735,7 +764,7 @@ module PDF
|
|
735
764
|
sig { returns(T.untyped) }
|
736
765
|
def to_a; end
|
737
766
|
|
738
|
-
sig { returns(T::Array[PDF::Reader::Reference]) }
|
767
|
+
sig { returns(T::Array[T.any(PDF::Reader::Reference, T::Hash[Symbol, T.untyped])]) }
|
739
768
|
def page_references; end
|
740
769
|
|
741
770
|
sig { returns(T::Boolean) }
|
@@ -765,16 +794,16 @@ module PDF
|
|
765
794
|
sig { returns(T.untyped) }
|
766
795
|
def object_streams; end
|
767
796
|
|
768
|
-
sig { params(obj: T::Hash[
|
797
|
+
sig { params(obj: T.any(PDF::Reader::Reference, T::Hash[Symbol, T.untyped])).returns(T::Array[T.any(PDF::Reader::Reference, T::Hash[Symbol, T.untyped])]) }
|
769
798
|
def get_page_objects(obj); end
|
770
799
|
|
771
800
|
sig { returns(Float) }
|
772
801
|
def read_version; end
|
773
802
|
|
774
|
-
sig { params(input: T.
|
803
|
+
sig { params(input: T.any(IO, Tempfile, StringIO, String)).returns(T.any(IO, Tempfile, StringIO)) }
|
775
804
|
def extract_io_from(input); end
|
776
805
|
|
777
|
-
sig { params(input:
|
806
|
+
sig { params(input: String).returns(String) }
|
778
807
|
def read_as_binary(input); end
|
779
808
|
end
|
780
809
|
|
@@ -783,9 +812,15 @@ module PDF
|
|
783
812
|
def initialize(stream)
|
784
813
|
@dict = T.let(T.unsafe(nil), T::Hash[Symbol, T.untyped])
|
785
814
|
@data = T.let(T.unsafe(nil), String)
|
815
|
+
@offsets = T.let(T.unsafe(nil), T.nilable(T::Hash[Integer, Integer]))
|
816
|
+
@buffer = T.let(T.unsafe(nil), T.nilable(PDF::Reader::Buffer))
|
786
817
|
end
|
787
818
|
|
788
|
-
sig {
|
819
|
+
sig {
|
820
|
+
params(objid: Integer).returns(
|
821
|
+
T.any(PDF::Reader::Reference, PDF::Reader::Token, Numeric, String, Symbol, T::Array[T.untyped], T::Hash[T.untyped, T.untyped], NilClass)
|
822
|
+
)
|
823
|
+
}
|
789
824
|
def [](objid); end
|
790
825
|
|
791
826
|
sig { returns(Integer) }
|
@@ -802,7 +837,7 @@ module PDF
|
|
802
837
|
end
|
803
838
|
|
804
839
|
class OverlappingRunsFilter
|
805
|
-
OVERLAPPING_THRESHOLD =
|
840
|
+
OVERLAPPING_THRESHOLD = T.let(T.unsafe(nil), Float)
|
806
841
|
|
807
842
|
sig { params(runs: T::Array[PDF::Reader::TextRun]).returns(T::Array[PDF::Reader::TextRun]) }
|
808
843
|
def self.exclude_redundant_runs(runs); end
|
@@ -811,6 +846,11 @@ module PDF
|
|
811
846
|
def self.detect_intersection(sweep_line_status, event_point); end
|
812
847
|
end
|
813
848
|
|
849
|
+
class NoTextFilter
|
850
|
+
sig { params(runs: T::Array[PDF::Reader::TextRun]).returns(T::Array[PDF::Reader::TextRun]) }
|
851
|
+
def self.exclude_empty_strings(runs); end
|
852
|
+
end
|
853
|
+
|
814
854
|
class EventPoint
|
815
855
|
sig { returns(Numeric) }
|
816
856
|
attr_reader :x
|
@@ -819,7 +859,10 @@ module PDF
|
|
819
859
|
attr_reader :run
|
820
860
|
|
821
861
|
sig { params(x: Numeric, run: PDF::Reader::TextRun).void }
|
822
|
-
def initialize(x, run)
|
862
|
+
def initialize(x, run)
|
863
|
+
@x = T.let(T.unsafe(nil), Numeric)
|
864
|
+
@run = T.let(T.unsafe(nil), PDF::Reader::TextRun)
|
865
|
+
end
|
823
866
|
|
824
867
|
sig { returns(T::Boolean) }
|
825
868
|
def start?; end
|
@@ -829,14 +872,22 @@ module PDF
|
|
829
872
|
sig { returns(PDF::Reader::ObjectHash) }
|
830
873
|
attr_reader :objects
|
831
874
|
|
832
|
-
sig { returns(T.untyped) }
|
875
|
+
sig { returns(T::Hash[Symbol, T.untyped]) }
|
833
876
|
attr_reader :page_object
|
834
877
|
|
835
|
-
sig { returns(T.untyped) }
|
878
|
+
sig { returns(T.any(PDF::Reader::ObjectCache, T::Hash[T.untyped, T.untyped])) }
|
836
879
|
attr_reader :cache
|
837
880
|
|
838
881
|
sig { params(objects: PDF::Reader::ObjectHash, pagenum: Integer, options: T::Hash[Symbol, T.untyped]).void }
|
839
|
-
def initialize(objects, pagenum, options = {})
|
882
|
+
def initialize(objects, pagenum, options = {})
|
883
|
+
@objects = T.let(T.unsafe(nil), PDF::Reader::ObjectHash)
|
884
|
+
@pagenum = T.let(T.unsafe(nil), Integer)
|
885
|
+
@page_object = T.let(T.unsafe(nil), T::Hash[Symbol, T.untyped])
|
886
|
+
@cache = T.let(T.unsafe(nil), T.any(PDF::Reader::ObjectCache, T::Hash[T.untyped, T.untyped]))
|
887
|
+
@attributes = T.let(T.unsafe(nil), T.nilable(T::Hash[Symbol, T.untyped]))
|
888
|
+
@root = T.let(T.unsafe(nil), T.nilable(T::Hash[Symbol, T.untyped]))
|
889
|
+
@resources = T.let(T.unsafe(nil), T.nilable(PDF::Reader::Resources))
|
890
|
+
end
|
840
891
|
|
841
892
|
sig { returns(Integer) }
|
842
893
|
def number; end
|
@@ -886,10 +937,10 @@ module PDF
|
|
886
937
|
sig { returns(PDF::Reader::Resources) }
|
887
938
|
def resources; end
|
888
939
|
|
889
|
-
sig { params(receivers: T.untyped, instructions:
|
940
|
+
sig { params(receivers: T::Array[T.untyped], instructions: String).void }
|
890
941
|
def content_stream(receivers, instructions); end
|
891
942
|
|
892
|
-
sig { params(receivers: T
|
943
|
+
sig { params(receivers: T::Array[Object], name: Symbol, params: T::Array[T.untyped]).void }
|
893
944
|
def callback(receivers, name, params = []); end
|
894
945
|
|
895
946
|
sig { returns(T.untyped) }
|
@@ -903,10 +954,21 @@ module PDF
|
|
903
954
|
end
|
904
955
|
|
905
956
|
class PageLayout
|
906
|
-
DEFAULT_FONT_SIZE =
|
957
|
+
DEFAULT_FONT_SIZE = T.let(T.unsafe(nil), Numeric)
|
907
958
|
|
908
959
|
sig { params(runs: T::Array[PDF::Reader::TextRun], mediabox: T.any(T::Array[Numeric], PDF::Reader::Rectangle)).void }
|
909
|
-
def initialize(runs, mediabox)
|
960
|
+
def initialize(runs, mediabox)
|
961
|
+
@mediabox = T.let(T.unsafe(nil), PDF::Reader::Rectangle)
|
962
|
+
@runs = T.let(T.unsafe(nil), T::Array[PDF::Reader::TextRun])
|
963
|
+
@mean_font_size = T.let(T.unsafe(nil), Numeric)
|
964
|
+
@median_glyph_width = T.let(T.unsafe(nil), Numeric)
|
965
|
+
@x_offset = T.let(T.unsafe(nil), Numeric)
|
966
|
+
@y_offset = T.let(T.unsafe(nil), Numeric)
|
967
|
+
@row_count = T.let(T.unsafe(nil), T.nilable(Integer))
|
968
|
+
@col_count = T.let(T.unsafe(nil), T.nilable(Integer))
|
969
|
+
@row_multiplier = T.let(T.unsafe(nil), T.nilable(Numeric))
|
970
|
+
@col_multiplier = T.let(T.unsafe(nil), T.nilable(Numeric))
|
971
|
+
end
|
910
972
|
|
911
973
|
sig { returns(String) }
|
912
974
|
def to_s; end
|
@@ -943,6 +1005,12 @@ module PDF
|
|
943
1005
|
|
944
1006
|
sig { params(mediabox: T.untyped).returns(T.untyped) }
|
945
1007
|
def process_mediabox(mediabox); end
|
1008
|
+
|
1009
|
+
sig { returns(Numeric) }
|
1010
|
+
def page_width; end
|
1011
|
+
|
1012
|
+
sig { returns(Numeric) }
|
1013
|
+
def page_height; end
|
946
1014
|
end
|
947
1015
|
|
948
1016
|
class PageState
|
@@ -1127,81 +1195,7 @@ module PDF
|
|
1127
1195
|
end
|
1128
1196
|
|
1129
1197
|
class PagesStrategy
|
1130
|
-
OPERATORS =
|
1131
|
-
'b' => :close_fill_stroke,
|
1132
|
-
'B' => :fill_stroke,
|
1133
|
-
'b*' => :close_fill_stroke_with_even_odd,
|
1134
|
-
'B*' => :fill_stroke_with_even_odd,
|
1135
|
-
'BDC' => :begin_marked_content_with_pl,
|
1136
|
-
'BI' => :begin_inline_image,
|
1137
|
-
'BMC' => :begin_marked_content,
|
1138
|
-
'BT' => :begin_text_object,
|
1139
|
-
'BX' => :begin_compatibility_section,
|
1140
|
-
'c' => :append_curved_segment,
|
1141
|
-
'cm' => :concatenate_matrix,
|
1142
|
-
'CS' => :set_stroke_color_space,
|
1143
|
-
'cs' => :set_nonstroke_color_space,
|
1144
|
-
'd' => :set_line_dash,
|
1145
|
-
'd0' => :set_glyph_width,
|
1146
|
-
'd1' => :set_glyph_width_and_bounding_box,
|
1147
|
-
'Do' => :invoke_xobject,
|
1148
|
-
'DP' => :define_marked_content_with_pl,
|
1149
|
-
'EI' => :end_inline_image,
|
1150
|
-
'EMC' => :end_marked_content,
|
1151
|
-
'ET' => :end_text_object,
|
1152
|
-
'EX' => :end_compatibility_section,
|
1153
|
-
'f' => :fill_path_with_nonzero,
|
1154
|
-
'F' => :fill_path_with_nonzero,
|
1155
|
-
'f*' => :fill_path_with_even_odd,
|
1156
|
-
'G' => :set_gray_for_stroking,
|
1157
|
-
'g' => :set_gray_for_nonstroking,
|
1158
|
-
'gs' => :set_graphics_state_parameters,
|
1159
|
-
'h' => :close_subpath,
|
1160
|
-
'i' => :set_flatness_tolerance,
|
1161
|
-
'ID' => :begin_inline_image_data,
|
1162
|
-
'j' => :set_line_join_style,
|
1163
|
-
'J' => :set_line_cap_style,
|
1164
|
-
'K' => :set_cmyk_color_for_stroking,
|
1165
|
-
'k' => :set_cmyk_color_for_nonstroking,
|
1166
|
-
'l' => :append_line,
|
1167
|
-
'm' => :begin_new_subpath,
|
1168
|
-
'M' => :set_miter_limit,
|
1169
|
-
'MP' => :define_marked_content_point,
|
1170
|
-
'n' => :end_path,
|
1171
|
-
'q' => :save_graphics_state,
|
1172
|
-
'Q' => :restore_graphics_state,
|
1173
|
-
're' => :append_rectangle,
|
1174
|
-
'RG' => :set_rgb_color_for_stroking,
|
1175
|
-
'rg' => :set_rgb_color_for_nonstroking,
|
1176
|
-
'ri' => :set_color_rendering_intent,
|
1177
|
-
's' => :close_and_stroke_path,
|
1178
|
-
'S' => :stroke_path,
|
1179
|
-
'SC' => :set_color_for_stroking,
|
1180
|
-
'sc' => :set_color_for_nonstroking,
|
1181
|
-
'SCN' => :set_color_for_stroking_and_special,
|
1182
|
-
'scn' => :set_color_for_nonstroking_and_special,
|
1183
|
-
'sh' => :paint_area_with_shading_pattern,
|
1184
|
-
'T*' => :move_to_start_of_next_line,
|
1185
|
-
'Tc' => :set_character_spacing,
|
1186
|
-
'Td' => :move_text_position,
|
1187
|
-
'TD' => :move_text_position_and_set_leading,
|
1188
|
-
'Tf' => :set_text_font_and_size,
|
1189
|
-
'Tj' => :show_text,
|
1190
|
-
'TJ' => :show_text_with_positioning,
|
1191
|
-
'TL' => :set_text_leading,
|
1192
|
-
'Tm' => :set_text_matrix_and_text_line_matrix,
|
1193
|
-
'Tr' => :set_text_rendering_mode,
|
1194
|
-
'Ts' => :set_text_rise,
|
1195
|
-
'Tw' => :set_word_spacing,
|
1196
|
-
'Tz' => :set_horizontal_text_scaling,
|
1197
|
-
'v' => :append_curved_segment_initial_point_replicated,
|
1198
|
-
'w' => :set_line_width,
|
1199
|
-
'W' => :set_clipping_path_with_nonzero,
|
1200
|
-
'W*' => :set_clipping_path_with_even_odd,
|
1201
|
-
'y' => :append_curved_segment_final_point_replicated,
|
1202
|
-
'\'' => :move_to_next_line_and_show_text,
|
1203
|
-
'"' => :set_spacing_next_line_show_text,
|
1204
|
-
}
|
1198
|
+
OPERATORS = T.let(T.unsafe(nil), T::Hash[String, Symbol])
|
1205
1199
|
end
|
1206
1200
|
|
1207
1201
|
class Parser
|
@@ -1349,25 +1343,28 @@ module PDF
|
|
1349
1343
|
end
|
1350
1344
|
|
1351
1345
|
class Reference
|
1352
|
-
sig { returns(
|
1346
|
+
sig { returns(Integer) }
|
1353
1347
|
attr_reader :id
|
1354
1348
|
|
1355
|
-
sig { returns(
|
1349
|
+
sig { returns(Integer) }
|
1356
1350
|
attr_reader :gen
|
1357
1351
|
|
1358
|
-
sig { params(id:
|
1359
|
-
def initialize(id, gen)
|
1352
|
+
sig { params(id: Integer, gen: Integer).void }
|
1353
|
+
def initialize(id, gen)
|
1354
|
+
@id = T.let(T.unsafe(nil), Integer)
|
1355
|
+
@gen = T.let(T.unsafe(nil), Integer)
|
1356
|
+
end
|
1360
1357
|
|
1361
|
-
sig { returns(T
|
1358
|
+
sig { returns(T::Array[PDF::Reader::Reference]) }
|
1362
1359
|
def to_a; end
|
1363
1360
|
|
1364
|
-
sig { returns(
|
1361
|
+
sig { returns(Integer) }
|
1365
1362
|
def to_i; end
|
1366
1363
|
|
1367
|
-
sig { params(obj:
|
1364
|
+
sig { params(obj: Object).returns(T::Boolean) }
|
1368
1365
|
def ==(obj); end
|
1369
1366
|
|
1370
|
-
sig { returns(
|
1367
|
+
sig { returns(Integer) }
|
1371
1368
|
def hash; end
|
1372
1369
|
end
|
1373
1370
|
|
@@ -1501,54 +1498,68 @@ module PDF
|
|
1501
1498
|
|
1502
1499
|
class SynchronizedCache
|
1503
1500
|
sig { void }
|
1504
|
-
def initialize
|
1501
|
+
def initialize
|
1502
|
+
@cache = T.let(T.unsafe(nil), T::Hash[Object, T.untyped])
|
1503
|
+
@mutex = T.let(T.unsafe(nil), Mutex)
|
1504
|
+
end
|
1505
1505
|
|
1506
|
-
sig { params(key:
|
1506
|
+
sig { params(key: Object).returns(T.untyped) }
|
1507
1507
|
def [](key); end
|
1508
1508
|
|
1509
|
-
sig { params(key:
|
1509
|
+
sig { params(key: Object, value: T.nilable(Object)).returns(T.untyped) }
|
1510
1510
|
def []=(key, value); end
|
1511
1511
|
end
|
1512
1512
|
|
1513
1513
|
class TextRun
|
1514
1514
|
include Comparable
|
1515
1515
|
|
1516
|
-
sig { returns(
|
1517
|
-
attr_reader :x
|
1518
|
-
|
1519
|
-
sig { returns(T.untyped) }
|
1520
|
-
attr_reader :y
|
1521
|
-
|
1522
|
-
sig { returns(T.untyped) }
|
1516
|
+
sig { returns(Numeric) }
|
1523
1517
|
attr_reader :width
|
1524
1518
|
|
1525
|
-
sig { returns(
|
1519
|
+
sig { returns(Numeric) }
|
1526
1520
|
attr_reader :font_size
|
1527
1521
|
|
1528
|
-
sig { returns(
|
1522
|
+
sig { returns(String) }
|
1529
1523
|
attr_reader :text
|
1530
1524
|
|
1525
|
+
sig { returns(PDF::Reader::Point) }
|
1526
|
+
attr_reader :origin
|
1527
|
+
|
1531
1528
|
sig do
|
1532
1529
|
params(
|
1533
|
-
x:
|
1534
|
-
y:
|
1535
|
-
width:
|
1536
|
-
font_size:
|
1537
|
-
text:
|
1530
|
+
x: Numeric,
|
1531
|
+
y: Numeric,
|
1532
|
+
width: Numeric,
|
1533
|
+
font_size: Numeric,
|
1534
|
+
text: String
|
1538
1535
|
).void
|
1539
1536
|
end
|
1540
|
-
def initialize(x, y, width, font_size, text)
|
1537
|
+
def initialize(x, y, width, font_size, text)
|
1538
|
+
@origin = T.let(T.unsafe(nil), PDF::Reader::Point)
|
1539
|
+
@width = T.let(T.unsafe(nil), Numeric)
|
1540
|
+
@font_size = T.let(T.unsafe(nil), Numeric)
|
1541
|
+
@text = T.let(T.unsafe(nil), String)
|
1542
|
+
@endx = T.let(T.unsafe(nil), T.nilable(Numeric))
|
1543
|
+
@endy = T.let(T.unsafe(nil), T.nilable(Numeric))
|
1544
|
+
@mergable_range = T.let(T.unsafe(nil), T.nilable(T::Range[Numeric]))
|
1545
|
+
end
|
1541
1546
|
|
1542
1547
|
sig { params(other: T.untyped).returns(T.untyped) }
|
1543
1548
|
def <=>(other); end
|
1544
1549
|
|
1545
|
-
sig { returns(
|
1550
|
+
sig { returns(Numeric) }
|
1546
1551
|
def endx; end
|
1547
1552
|
|
1548
|
-
sig { returns(
|
1553
|
+
sig { returns(Numeric) }
|
1549
1554
|
def endy; end
|
1550
1555
|
|
1551
|
-
sig { returns(
|
1556
|
+
sig { returns(Numeric) }
|
1557
|
+
def x; end
|
1558
|
+
|
1559
|
+
sig { returns(Numeric) }
|
1560
|
+
def y; end
|
1561
|
+
|
1562
|
+
sig { returns(Numeric) }
|
1552
1563
|
def mean_character_width; end
|
1553
1564
|
|
1554
1565
|
sig { params(other: PDF::Reader::TextRun).returns(T::Boolean) }
|
@@ -1557,22 +1568,22 @@ module PDF
|
|
1557
1568
|
sig { params(other: PDF::Reader::TextRun).returns(PDF::Reader::TextRun) }
|
1558
1569
|
def +(other); end
|
1559
1570
|
|
1560
|
-
sig { returns(
|
1571
|
+
sig { returns(String) }
|
1561
1572
|
def inspect; end
|
1562
1573
|
|
1563
|
-
sig { params(other_run: T.untyped).returns(T
|
1574
|
+
sig { params(other_run: T.untyped).returns(T::Boolean) }
|
1564
1575
|
def intersect?(other_run); end
|
1565
1576
|
|
1566
|
-
sig { params(other_run: T.untyped).returns(
|
1577
|
+
sig { params(other_run: T.untyped).returns(Numeric) }
|
1567
1578
|
def intersection_area_percent(other_run); end
|
1568
1579
|
|
1569
|
-
sig { returns(
|
1580
|
+
sig { returns(Numeric) }
|
1570
1581
|
def area; end
|
1571
1582
|
|
1572
|
-
sig { returns(T
|
1583
|
+
sig { returns(T::Range[Numeric]) }
|
1573
1584
|
def mergable_range; end
|
1574
1585
|
|
1575
|
-
sig { returns(
|
1586
|
+
sig { returns(Numeric) }
|
1576
1587
|
def character_count; end
|
1577
1588
|
end
|
1578
1589
|
|
@@ -1582,114 +1593,121 @@ module PDF
|
|
1582
1593
|
end
|
1583
1594
|
|
1584
1595
|
class TransformationMatrix
|
1585
|
-
sig { returns(
|
1596
|
+
sig { returns(Numeric) }
|
1586
1597
|
attr_reader :a
|
1587
1598
|
|
1588
|
-
sig { returns(
|
1599
|
+
sig { returns(Numeric) }
|
1589
1600
|
attr_reader :b
|
1590
1601
|
|
1591
|
-
sig { returns(
|
1602
|
+
sig { returns(Numeric) }
|
1592
1603
|
attr_reader :c
|
1593
1604
|
|
1594
|
-
sig { returns(
|
1605
|
+
sig { returns(Numeric) }
|
1595
1606
|
attr_reader :d
|
1596
1607
|
|
1597
|
-
sig { returns(
|
1608
|
+
sig { returns(Numeric) }
|
1598
1609
|
attr_reader :e
|
1599
1610
|
|
1600
|
-
sig { returns(
|
1611
|
+
sig { returns(Numeric) }
|
1601
1612
|
attr_reader :f
|
1602
1613
|
|
1603
1614
|
sig do
|
1604
1615
|
params(
|
1605
|
-
a:
|
1606
|
-
b:
|
1607
|
-
c:
|
1608
|
-
d:
|
1609
|
-
e:
|
1610
|
-
f:
|
1616
|
+
a: Numeric,
|
1617
|
+
b: Numeric,
|
1618
|
+
c: Numeric,
|
1619
|
+
d: Numeric,
|
1620
|
+
e: Numeric,
|
1621
|
+
f: Numeric
|
1611
1622
|
).void
|
1612
1623
|
end
|
1613
|
-
def initialize(a, b, c, d, e, f)
|
1624
|
+
def initialize(a, b, c, d, e, f)
|
1625
|
+
@a = T.let(T.unsafe(nil), Numeric)
|
1626
|
+
@b = T.let(T.unsafe(nil), Numeric)
|
1627
|
+
@c = T.let(T.unsafe(nil), Numeric)
|
1628
|
+
@d = T.let(T.unsafe(nil), Numeric)
|
1629
|
+
@e = T.let(T.unsafe(nil), Numeric)
|
1630
|
+
@f = T.let(T.unsafe(nil), Numeric)
|
1631
|
+
end
|
1614
1632
|
|
1615
|
-
sig { returns(
|
1633
|
+
sig { returns(String) }
|
1616
1634
|
def inspect; end
|
1617
1635
|
|
1618
|
-
sig { returns(T
|
1636
|
+
sig { returns(T::Array[Numeric]) }
|
1619
1637
|
def to_a; end
|
1620
1638
|
|
1621
1639
|
sig do
|
1622
1640
|
params(
|
1623
|
-
a:
|
1624
|
-
b:
|
1625
|
-
c:
|
1626
|
-
d:
|
1627
|
-
e:
|
1628
|
-
f:
|
1629
|
-
).returns(
|
1641
|
+
a: Numeric,
|
1642
|
+
b: Numeric,
|
1643
|
+
c: Numeric,
|
1644
|
+
d: Numeric,
|
1645
|
+
e: Numeric,
|
1646
|
+
f: Numeric
|
1647
|
+
).returns(PDF::Reader::TransformationMatrix)
|
1630
1648
|
end
|
1631
|
-
def multiply!(a, b
|
1649
|
+
def multiply!(a, b, c, d, e, f); end
|
1632
1650
|
|
1633
|
-
sig { params(e2:
|
1651
|
+
sig { params(e2: Numeric).void }
|
1634
1652
|
def horizontal_displacement_multiply!(e2); end
|
1635
1653
|
|
1636
1654
|
sig do
|
1637
1655
|
params(
|
1638
|
-
a2:
|
1639
|
-
b2:
|
1640
|
-
c2:
|
1641
|
-
d2:
|
1642
|
-
e2:
|
1643
|
-
f2:
|
1644
|
-
).
|
1656
|
+
a2: Numeric,
|
1657
|
+
b2: Numeric,
|
1658
|
+
c2: Numeric,
|
1659
|
+
d2: Numeric,
|
1660
|
+
e2: Numeric,
|
1661
|
+
f2: Numeric
|
1662
|
+
).void
|
1645
1663
|
end
|
1646
1664
|
def horizontal_displacement_multiply_reversed!(a2, b2, c2, d2, e2, f2); end
|
1647
1665
|
|
1648
1666
|
sig do
|
1649
1667
|
params(
|
1650
|
-
a2:
|
1651
|
-
b2:
|
1652
|
-
c2:
|
1653
|
-
d2:
|
1654
|
-
e2:
|
1655
|
-
f2:
|
1656
|
-
).
|
1668
|
+
a2: Numeric,
|
1669
|
+
b2: Numeric,
|
1670
|
+
c2: Numeric,
|
1671
|
+
d2: Numeric,
|
1672
|
+
e2: Numeric,
|
1673
|
+
f2: Numeric
|
1674
|
+
).void
|
1657
1675
|
end
|
1658
1676
|
def xy_scaling_multiply!(a2, b2, c2, d2, e2, f2); end
|
1659
1677
|
|
1660
1678
|
sig do
|
1661
1679
|
params(
|
1662
|
-
a2:
|
1663
|
-
b2:
|
1664
|
-
c2:
|
1665
|
-
d2:
|
1666
|
-
e2:
|
1667
|
-
f2:
|
1668
|
-
).
|
1680
|
+
a2: Numeric,
|
1681
|
+
b2: Numeric,
|
1682
|
+
c2: Numeric,
|
1683
|
+
d2: Numeric,
|
1684
|
+
e2: Numeric,
|
1685
|
+
f2: Numeric
|
1686
|
+
).void
|
1669
1687
|
end
|
1670
1688
|
def xy_scaling_multiply_reversed!(a2, b2, c2, d2, e2, f2); end
|
1671
1689
|
|
1672
1690
|
sig do
|
1673
1691
|
params(
|
1674
|
-
a2:
|
1675
|
-
b2:
|
1676
|
-
c2:
|
1677
|
-
d2:
|
1678
|
-
e2:
|
1679
|
-
f2:
|
1680
|
-
).
|
1692
|
+
a2: Numeric,
|
1693
|
+
b2: Numeric,
|
1694
|
+
c2: Numeric,
|
1695
|
+
d2: Numeric,
|
1696
|
+
e2: Numeric,
|
1697
|
+
f2: Numeric
|
1698
|
+
).void
|
1681
1699
|
end
|
1682
1700
|
def regular_multiply!(a2, b2, c2, d2, e2, f2); end
|
1683
1701
|
|
1684
1702
|
sig do
|
1685
1703
|
params(
|
1686
|
-
a2:
|
1687
|
-
b2:
|
1688
|
-
c2:
|
1689
|
-
d2:
|
1690
|
-
e2:
|
1691
|
-
f2:
|
1692
|
-
).
|
1704
|
+
a2: Numeric,
|
1705
|
+
b2: Numeric,
|
1706
|
+
c2: Numeric,
|
1707
|
+
d2: Numeric,
|
1708
|
+
e2: Numeric,
|
1709
|
+
f2: Numeric
|
1710
|
+
).void
|
1693
1711
|
end
|
1694
1712
|
def faster_multiply!(a2, b2, c2, d2, e2, f2); end
|
1695
1713
|
end
|
@@ -1819,12 +1837,18 @@ module PDF
|
|
1819
1837
|
|
1820
1838
|
class XRef
|
1821
1839
|
include Enumerable
|
1840
|
+
extend T::Generic # Provides `type_member` helper
|
1822
1841
|
|
1823
|
-
sig { returns(T.untyped) }
|
1842
|
+
sig { returns(T::Hash[Symbol, T.untyped]) }
|
1824
1843
|
attr_reader :trailer
|
1825
1844
|
|
1826
|
-
sig { params(io: T.
|
1827
|
-
def initialize(io)
|
1845
|
+
sig { params(io: T.any(IO, Tempfile, StringIO)).void }
|
1846
|
+
def initialize(io)
|
1847
|
+
@io = T.let(T.unsafe(nil), T.any(IO, Tempfile, StringIO))
|
1848
|
+
@junk_offset = T.let(T.unsafe(nil), Integer)
|
1849
|
+
@xref = T.let(T.unsafe(nil), T::Hash[Integer, T::Hash[Integer, Integer]])
|
1850
|
+
@trailer = T.let(T.unsafe(nil), T::Hash[Symbol, T.untyped])
|
1851
|
+
end
|
1828
1852
|
|
1829
1853
|
sig { returns(T.untyped) }
|
1830
1854
|
def size; end
|
@@ -1888,7 +1912,9 @@ module PDF
|
|
1888
1912
|
|
1889
1913
|
class Depredict
|
1890
1914
|
sig { params(options: T::Hash[T.untyped, T.untyped]).void }
|
1891
|
-
def initialize(options = {})
|
1915
|
+
def initialize(options = {})
|
1916
|
+
@options = T.let(T.unsafe(nil), T::Hash[T.untyped, T.untyped])
|
1917
|
+
end
|
1892
1918
|
|
1893
1919
|
sig { params(data: String).returns(String) }
|
1894
1920
|
def filter(data); end
|
@@ -1949,17 +1975,14 @@ module PDF
|
|
1949
1975
|
|
1950
1976
|
module WidthCalculator
|
1951
1977
|
class BuiltIn
|
1952
|
-
BUILTINS = [
|
1953
|
-
|
1954
|
-
|
1955
|
-
:Symbol,
|
1956
|
-
:"Times-Roman", :"Times-Bold", :"Times-BoldItalic", :"Times-Italic",
|
1957
|
-
:ZapfDingbats
|
1958
|
-
]
|
1978
|
+
BUILTINS = T.let(T.unsafe(nil), T::Array[Symbol])
|
1979
|
+
|
1980
|
+
@@all_metrics = T.let(T.unsafe(nil), T.nilable(PDF::Reader::SynchronizedCache))
|
1959
1981
|
|
1960
1982
|
sig { params(font: PDF::Reader::Font).void }
|
1961
1983
|
def initialize(font)
|
1962
1984
|
@font = T.let(T.unsafe(nil), PDF::Reader::Font)
|
1985
|
+
@metrics = T.let(T.unsafe(nil), AFM::Font)
|
1963
1986
|
end
|
1964
1987
|
|
1965
1988
|
sig { params(code_point: T.nilable(Integer)).returns(Numeric) }
|