pdf-reader 2.9.2 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +8 -0
  3. data/Rakefile +1 -1
  4. data/lib/pdf/reader/buffer.rb +1 -1
  5. data/lib/pdf/reader/cid_widths.rb +7 -5
  6. data/lib/pdf/reader/cmap.rb +1 -1
  7. data/lib/pdf/reader/encoding.rb +4 -4
  8. data/lib/pdf/reader/error.rb +0 -4
  9. data/lib/pdf/reader/filter/depredict.rb +2 -2
  10. data/lib/pdf/reader/font.rb +10 -11
  11. data/lib/pdf/reader/font_descriptor.rb +3 -1
  12. data/lib/pdf/reader/form_xobject.rb +4 -1
  13. data/lib/pdf/reader/glyph_hash.rb +13 -5
  14. data/lib/pdf/reader/lzw.rb +25 -10
  15. data/lib/pdf/reader/no_text_filter.rb +14 -0
  16. data/lib/pdf/reader/object_hash.rb +15 -9
  17. data/lib/pdf/reader/object_stream.rb +3 -3
  18. data/lib/pdf/reader/overlapping_runs_filter.rb +1 -1
  19. data/lib/pdf/reader/page.rb +26 -7
  20. data/lib/pdf/reader/page_layout.rb +1 -1
  21. data/lib/pdf/reader/page_state.rb +7 -1
  22. data/lib/pdf/reader/page_text_receiver.rb +2 -0
  23. data/lib/pdf/reader/pages_strategy.rb +1 -1
  24. data/lib/pdf/reader/reference.rb +3 -2
  25. data/lib/pdf/reader/resources.rb +3 -2
  26. data/lib/pdf/reader/stream.rb +1 -1
  27. data/lib/pdf/reader/synchronized_cache.rb +1 -1
  28. data/lib/pdf/reader/text_run.rb +5 -2
  29. data/lib/pdf/reader/transformation_matrix.rb +8 -8
  30. data/lib/pdf/reader/type_check.rb +46 -0
  31. data/lib/pdf/reader/width_calculator/built_in.rb +4 -3
  32. data/lib/pdf/reader/width_calculator/composite.rb +6 -2
  33. data/lib/pdf/reader/width_calculator/true_type.rb +10 -12
  34. data/lib/pdf/reader/width_calculator/type_one_or_three.rb +6 -5
  35. data/lib/pdf/reader/width_calculator/type_zero.rb +6 -3
  36. data/lib/pdf/reader/xref.rb +3 -3
  37. data/lib/pdf/reader.rb +5 -10
  38. data/rbi/pdf-reader.rbi +428 -358
  39. 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(T.untyped) }
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 = {}); end
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(T::Hash[T.untyped, T.untyped])) }
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 = [0x00, 0x09, 0x0A, 0x0C, 0x0D, 0x20]
74
- TOKEN_DELIMITER = [0x25, 0x3C, 0x3E, 0x28, 0x5B, 0x7B, 0x29, 0x5D, 0x7D, 0x2F]
75
- LEFT_PAREN = "("
76
- LESS_THAN = "<"
77
- STREAM = "stream"
78
- ID = "ID"
79
- FWD_SLASH = "/"
80
- NULL_BYTE = "\x00"
81
- CR = "\r"
82
- LF = "\n"
83
- CRLF = "\r\n"
84
- WHITE_SPACE = [LF, CR, ' ']
85
- TRAILING_BYTECOUNT = 5000
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, File), opts: T::Hash[Symbol, T.untyped]).void }
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, File))
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
 
@@ -145,31 +151,23 @@ module PDF
145
151
  end
146
152
 
147
153
  class CidWidths
148
- sig { params(default: T.untyped, array: T.untyped).void }
149
- def initialize(default, array); end
154
+ sig { params(default: Numeric, array: T::Array[Numeric]).void }
155
+ def initialize(default, array)
156
+ @widths = T.let(T.unsafe(nil), T::Hash[Numeric, Numeric])
157
+ end
150
158
 
151
- sig { params(default: T.untyped, array: T.untyped).returns(T.untyped) }
159
+ sig { params(default: Numeric, array: T::Array[Numeric]).returns(T::Hash[Numeric, Numeric]) }
152
160
  def parse_array(default, array); end
153
161
 
154
- sig { params(first: T.untyped, widths: T.untyped).returns(T.untyped) }
162
+ sig { params(first: Integer, widths: T::Array[Numeric]).returns(T::Hash[Numeric, Numeric]) }
155
163
  def parse_first_form(first, widths); end
156
164
 
157
- sig { params(first: T.untyped, final: T.untyped, width: T.untyped).returns(T.untyped) }
165
+ sig { params(first: Integer, final: Integer, width: Numeric).returns(T::Hash[Numeric, Numeric]) }
158
166
  def parse_second_form(first, final, width); end
159
167
  end
160
168
 
161
169
  class CMap
162
- CMAP_KEYWORDS = {
163
- "begincodespacerange" => 1,
164
- "endcodespacerange" => 1,
165
- "beginbfchar" => 1,
166
- "endbfchar" => 1,
167
- "beginbfrange" => 1,
168
- "endbfrange" => 1,
169
- "begin" => 1,
170
- "begincmap" => 1,
171
- "def" => 1
172
- }
170
+ CMAP_KEYWORDS = T.let(T.unsafe(nil), T::Hash[String, Symbol])
173
171
 
174
172
  sig { returns(T.untyped) }
175
173
  attr_reader :map
@@ -208,20 +206,27 @@ module PDF
208
206
  end
209
207
 
210
208
  class Encoding
211
- CONTROL_CHARS = [0,1,2,3,4,5,6,7,8,11,12,14,15,16,17,18,19,20,21,22,23,
212
- 24,25,26,27,28,29,30,31]
213
- UNKNOWN_CHAR = 0x25AF
209
+ CONTROL_CHARS = T.let(T.unsafe(nil), T::Array[Integer])
210
+ UNKNOWN_CHAR = T.let(T.unsafe(nil), Integer)
214
211
 
215
- sig { returns(T.untyped) }
212
+ sig { returns(String) }
216
213
  attr_reader :unpack
217
214
 
218
215
  sig { params(enc: T.untyped).void }
219
- def initialize(enc); end
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
220
225
 
221
- sig { params(diff: T.untyped).returns(T.untyped) }
226
+ sig { params(diff: T::Array[T.any(Integer, Symbol)]).returns(T::Hash[Integer, Integer]) }
222
227
  def differences=(diff); end
223
228
 
224
- sig { returns(T.untyped) }
229
+ sig { returns(T::Hash[Integer, Integer]) }
225
230
  def differences; end
226
231
 
227
232
  sig { params(str: String).returns(String) }
@@ -233,31 +238,31 @@ module PDF
233
238
  sig { params(glyph_code: Integer).returns(T::Array[Symbol]) }
234
239
  def int_to_name(glyph_code); end
235
240
 
236
- sig { returns(T.untyped) }
241
+ sig { returns(T::Hash[Integer, Integer]) }
237
242
  def default_mapping; end
238
243
 
239
- sig { params(glyph_code: T.untyped).returns(T.untyped) }
244
+ sig { params(glyph_code: Integer).returns(String) }
240
245
  def internal_int_to_utf8_string(glyph_code); end
241
246
 
242
- sig { returns(T.untyped) }
247
+ sig { returns(T::Boolean) }
243
248
  def utf8_conversion_impossible?; end
244
249
 
245
- sig { params(times: T.untyped).returns(T.untyped) }
250
+ sig { params(times: Integer).returns(String) }
246
251
  def little_boxes(times); end
247
252
 
248
- sig { params(str: T.untyped).returns(T.untyped) }
253
+ sig { params(str: String).returns(String) }
249
254
  def convert_to_utf8(str); end
250
255
 
251
- sig { params(enc: T.untyped).returns(T.untyped) }
256
+ sig { params(enc: T.untyped).returns(String) }
252
257
  def get_unpack(enc); end
253
258
 
254
- sig { params(enc: T.untyped).returns(T.untyped) }
259
+ sig { params(enc: T.untyped).returns(T.nilable(String)) }
255
260
  def get_mapping_file(enc); end
256
261
 
257
- sig { returns(T.untyped) }
262
+ sig { returns(PDF::Reader::GlyphHash) }
258
263
  def glyphlist; end
259
264
 
260
- sig { params(file: T.untyped).returns(T.untyped) }
265
+ sig { params(file: String).void }
261
266
  def load_mapping(file); end
262
267
  end
263
268
 
@@ -279,9 +284,6 @@ module PDF
279
284
 
280
285
  sig { params(object: Object, name: String).void }
281
286
  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
285
287
  end
286
288
 
287
289
  class MalformedPDFError < RuntimeError
@@ -300,138 +302,146 @@ module PDF
300
302
  end
301
303
 
302
304
  class Font
303
- sig { returns(T.untyped) }
305
+ sig { returns(T.nilable(Symbol)) }
304
306
  attr_accessor :subtype
305
307
 
306
- sig { returns(T.untyped) }
308
+ sig { returns(PDF::Reader::Encoding) }
307
309
  attr_accessor :encoding
308
310
 
309
- sig { returns(T.untyped) }
311
+ sig { returns(T::Array[PDF::Reader::Font]) }
310
312
  attr_accessor :descendantfonts
311
313
 
312
- sig { returns(T.untyped) }
314
+ sig { returns(PDF::Reader::CMap) }
313
315
  attr_accessor :tounicode
314
316
 
315
- sig { returns(T.untyped) }
317
+ sig { returns(T::Array[Integer]) }
316
318
  attr_reader :widths
317
319
 
318
- sig { returns(T.untyped) }
320
+ sig { returns(T.nilable(Integer)) }
319
321
  attr_reader :first_char
320
322
 
321
- sig { returns(T.untyped) }
323
+ sig { returns(T.nilable(Integer)) }
322
324
  attr_reader :last_char
323
325
 
324
- sig { returns(T.untyped) }
326
+ sig { returns(T.nilable(Symbol)) }
325
327
  attr_reader :basefont
326
328
 
327
- sig { returns(T.untyped) }
329
+ sig { returns(T.nilable(PDF::Reader::FontDescriptor)) }
328
330
  attr_reader :font_descriptor
329
331
 
330
- sig { returns(T.untyped) }
332
+ sig { returns(T::Array[Numeric]) }
331
333
  attr_reader :cid_widths
332
334
 
333
- sig { returns(T.untyped) }
335
+ sig { returns(Numeric) }
334
336
  attr_reader :cid_default_width
335
337
 
336
- sig { params(ohash: T.untyped, obj: T.untyped).void }
338
+ sig { params(ohash: PDF::Reader::ObjectHash, obj: T::Hash[Symbol, T.untyped]).void }
337
339
  def initialize(ohash, obj); end
338
340
 
339
- sig { params(params: T.untyped).returns(T.untyped) }
341
+ sig { params(params: T.any(Integer, String, T::Array[T.untyped])).returns(String) }
340
342
  def to_utf8(params); end
341
343
 
342
- sig { params(data: T.untyped).returns(T.untyped) }
344
+ sig { params(data: String).returns(T::Array[T.nilable(T.any(Numeric, String))]) }
343
345
  def unpack(data); end
344
346
 
345
- sig { params(code_point: T.untyped).returns(T.untyped) }
347
+ sig { params(code_point: T.any(String, Integer)).returns(T.untyped) }
346
348
  def glyph_width(code_point); end
347
349
 
348
- sig { params(font_name: T.untyped).returns(T.untyped) }
350
+ sig { params(font_name: Symbol).returns(PDF::Reader::Encoding) }
349
351
  def default_encoding(font_name); end
350
352
 
351
- sig { returns(T.untyped) }
353
+ sig {
354
+ returns(
355
+ T.any(
356
+ PDF::Reader::WidthCalculator::BuiltIn,
357
+ PDF::Reader::WidthCalculator::Composite,
358
+ PDF::Reader::WidthCalculator::TrueType,
359
+ PDF::Reader::WidthCalculator::TypeOneOrThree,
360
+ PDF::Reader::WidthCalculator::TypeZero,
361
+ )
362
+ )
363
+ }
352
364
  def build_width_calculator; end
353
365
 
354
- sig { params(obj: T.untyped).returns(T.untyped) }
366
+ sig { params(obj: T.untyped).void }
355
367
  def extract_base_info(obj); end
356
368
 
357
- sig { params(obj: T.untyped).returns(T.untyped) }
369
+ sig { params(obj: T.untyped).void }
358
370
  def extract_descriptor(obj); end
359
371
 
360
- sig { params(obj: T.untyped).returns(T.untyped) }
372
+ sig { params(obj: T.untyped).void }
361
373
  def extract_descendants(obj); end
362
374
 
363
- sig { params(params: T.untyped).returns(T.untyped) }
375
+ sig { params(params: T.any(Integer, String, T::Array[T.untyped])).returns(String) }
364
376
  def to_utf8_via_cmap(params); end
365
377
 
366
- sig { params(params: T.untyped).returns(T.untyped) }
378
+ sig { params(params: T.any(Integer, String, T::Array[T.untyped])).returns(String) }
367
379
  def to_utf8_via_encoding(params); end
368
380
  end
369
381
 
370
382
  class FontDescriptor
371
- sig { returns(T.untyped) }
383
+ sig { returns(String) }
372
384
  attr_reader :font_name
373
385
 
374
- sig { returns(T.untyped) }
386
+ sig { returns(T.nilable(String)) }
375
387
  attr_reader :font_family
376
388
 
377
- sig { returns(T.untyped) }
389
+ sig { returns(Symbol) }
378
390
  attr_reader :font_stretch
379
391
 
380
- sig { returns(T.untyped) }
392
+ sig { returns(Numeric) }
381
393
  attr_reader :font_weight
382
394
 
383
- sig { returns(T.untyped) }
395
+ sig { returns(T::Array[Numeric]) }
384
396
  attr_reader :font_bounding_box
385
397
 
386
- sig { returns(T.untyped) }
398
+ sig { returns(Numeric) }
387
399
  attr_reader :cap_height
388
400
 
389
- sig { returns(T.untyped) }
401
+ sig { returns(Numeric) }
390
402
  attr_reader :ascent
391
403
 
392
- sig { returns(T.untyped) }
404
+ sig { returns(Numeric) }
393
405
  attr_reader :descent
394
406
 
395
- sig { returns(T.untyped) }
407
+ sig { returns(Numeric) }
396
408
  attr_reader :leading
397
409
 
398
- sig { returns(T.untyped) }
410
+ sig { returns(Numeric) }
399
411
  attr_reader :avg_width
400
412
 
401
- sig { returns(T.untyped) }
413
+ sig { returns(Numeric) }
402
414
  attr_reader :max_width
403
415
 
404
- sig { returns(T.untyped) }
416
+ sig { returns(Numeric) }
405
417
  attr_reader :missing_width
406
418
 
407
- sig { returns(T.untyped) }
419
+ sig { returns(T.nilable(Numeric)) }
408
420
  attr_reader :italic_angle
409
421
 
410
- sig { returns(T.untyped) }
422
+ sig { returns(T.nilable(Numeric)) }
411
423
  attr_reader :stem_v
412
424
 
413
- sig { returns(T.untyped) }
425
+ sig { returns(T.nilable(Numeric)) }
414
426
  attr_reader :x_height
415
427
 
416
- sig { returns(T.untyped) }
428
+ sig { returns(Integer) }
417
429
  attr_reader :font_flags
418
430
 
419
431
  sig { params(ohash: PDF::Reader::ObjectHash, fd_hash: T::Hash[T.untyped, T.untyped]).void }
420
432
  def initialize(ohash, fd_hash); end
421
433
 
422
- sig { params(char_code: T.untyped).returns(T.untyped) }
434
+ sig { params(char_code: Integer).returns(Numeric) }
423
435
  def glyph_width(char_code); end
424
436
 
425
- sig { returns(T.untyped) }
437
+ sig { returns(Numeric) }
426
438
  def glyph_to_pdf_scale_factor; end
427
439
 
428
- sig { returns(T.untyped) }
440
+ sig { returns(TTFunk::File) }
429
441
  def ttf_program_stream; end
430
442
  end
431
443
 
432
444
  class FormXObject
433
- include ResourceMethods
434
-
435
445
  sig { returns(T.untyped) }
436
446
  attr_reader :xobject
437
447
 
@@ -467,16 +477,22 @@ module PDF
467
477
  end
468
478
 
469
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
+
470
483
  sig { void }
471
- def initialize; end
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
472
488
 
473
- sig { params(name: T.untyped).returns(T.untyped) }
489
+ sig { params(name: T.nilable(Symbol)).returns(T.nilable(Integer)) }
474
490
  def name_to_unicode(name); end
475
491
 
476
- sig { params(codepoint: T.untyped).returns(T.untyped) }
492
+ sig { params(codepoint: T.nilable(Integer)).returns(T::Array[Symbol]) }
477
493
  def unicode_to_name(codepoint); end
478
494
 
479
- sig { returns(T.untyped) }
495
+ sig { returns([T::Hash[Symbol, Integer], T::Hash[Integer, T::Array[Symbol]]]) }
480
496
  def load_adobe_glyph_mapping; end
481
497
  end
482
498
 
@@ -517,34 +533,43 @@ module PDF
517
533
  CODE_CLEAR_TABLE = 256
518
534
 
519
535
  class BitStream
520
- sig { params(data: T.untyped, bits_in_chunk: T.untyped).void }
521
- def initialize(data, bits_in_chunk); end
536
+ sig { params(data: String, bits_in_chunk: Integer).void }
537
+ def initialize(data, bits_in_chunk)
538
+ @data = T.let(T.unsafe(nil), String)
539
+ @bits_in_chunk = T.let(T.unsafe(nil), Integer)
540
+ @current_pos = T.let(T.unsafe(nil), Integer)
541
+ @bits_left_in_byte = T.let(T.unsafe(nil), Integer)
522
542
 
523
- sig { params(bits_in_chunk: T.untyped).returns(T.untyped) }
543
+ end
544
+
545
+ sig { params(bits_in_chunk: Integer).void }
524
546
  def set_bits_in_chunk(bits_in_chunk); end
525
547
 
526
- sig { returns(T.untyped) }
548
+ sig { returns(Integer) }
527
549
  def read; end
528
550
  end
529
551
 
530
- class StringTable < Hash
531
- sig { returns(T.untyped) }
552
+ class StringTable
553
+ sig { returns(Integer) }
532
554
  attr_reader :string_table_pos
533
555
 
534
556
  sig { void }
535
- def initialize; end
557
+ def initialize
558
+ @data = T.let(T.unsafe(nil), T::Hash[Integer, String])
559
+ @string_table_pos = T.let(T.unsafe(nil), Integer)
560
+ end
536
561
 
537
- sig { params(key: T.untyped).returns(T.untyped) }
562
+ sig { params(key: Integer).returns(T.nilable(String)) }
538
563
  def [](key); end
539
564
 
540
- sig { params(string: T.untyped).returns(T.untyped) }
565
+ sig { params(string: String).void }
541
566
  def add(string); end
542
567
  end
543
568
 
544
- sig { params(data: T.untyped).returns(T.untyped) }
569
+ sig { params(data: String).returns(String) }
545
570
  def self.decode(data); end
546
571
 
547
- sig { params(string_table: T.untyped, some_code: T.untyped, other_code: T.untyped).returns(T.untyped) }
572
+ sig { params(string_table: PDF::Reader::LZW::StringTable, some_code: T.nilable(Integer), other_code: T.nilable(Integer)).returns(String) }
548
573
  def self.create_new_string(string_table, some_code, other_code); end
549
574
  end
550
575
 
@@ -617,25 +642,45 @@ module PDF
617
642
  sig { returns(T.untyped) }
618
643
  attr_accessor :default
619
644
 
620
- sig { returns(T.untyped) }
645
+ sig { returns(T::Hash[Symbol, T.untyped]) }
621
646
  attr_reader :trailer
622
647
 
623
- sig { returns(T.untyped) }
648
+ sig { returns(Float) }
624
649
  attr_reader :pdf_version
625
650
 
626
- sig { returns(T.untyped) }
651
+ sig { returns(
652
+ T.any(
653
+ PDF::Reader::NullSecurityHandler,
654
+ PDF::Reader::AesV2SecurityHandler,
655
+ PDF::Reader::AesV3SecurityHandler,
656
+ PDF::Reader::Rc4SecurityHandler,
657
+ )) }
627
658
  attr_reader :sec_handler
628
659
 
629
- sig { params(input: T.untyped, opts: T.untyped).void }
630
- def initialize(input, opts = {}); end
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
631
676
 
632
- sig { params(ref: T.untyped).returns(T.untyped) }
677
+ sig { params(ref: T.any(Integer, PDF::Reader::Reference)).returns(T.nilable(Symbol)) }
633
678
  def obj_type(ref); end
634
679
 
635
- sig { params(ref: T.untyped).returns(T.untyped) }
680
+ sig { params(ref: T.any(Integer, PDF::Reader::Reference)).returns(T::Boolean) }
636
681
  def stream?(ref); end
637
682
 
638
- sig { params(key: T.untyped).returns(T.untyped) }
683
+ sig { params(key: T.any(Integer, PDF::Reader::Reference)).returns(T.untyped) }
639
684
  def [](key); end
640
685
 
641
686
  sig { params(key: T.untyped).returns(T.untyped) }
@@ -647,7 +692,7 @@ module PDF
647
692
  sig { params(key: T.untyped).returns(T.nilable(T::Array[Numeric])) }
648
693
  def deref_array_of_numbers(key); end
649
694
 
650
- sig { params(key: T.untyped).returns(T.nilable(T:Hash[Symbol, T.untyped])) }
695
+ sig { params(key: T.untyped).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
651
696
  def deref_hash(key); end
652
697
 
653
698
  sig { params(key: T.untyped).returns(T.nilable(Symbol)) }
@@ -674,10 +719,10 @@ module PDF
674
719
  sig { params(key: T.untyped).returns(T.untyped) }
675
720
  def deref!(key); end
676
721
 
677
- sig { params(key: T.untyped).returns(T::Array[T.untyped]) }
722
+ sig { params(key: T.untyped).returns(T.nilable(T::Array[T.untyped])) }
678
723
  def deref_array!(key); end
679
724
 
680
- sig { params(key: T.untyped).returns(T::Hash[Symbol, T.untyped]) }
725
+ sig { params(key: T.untyped).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
681
726
  def deref_hash!(key); end
682
727
 
683
728
  sig { params(key: T.untyped, local_default: T.untyped).returns(T.untyped) }
@@ -719,7 +764,7 @@ module PDF
719
764
  sig { returns(T.untyped) }
720
765
  def to_a; end
721
766
 
722
- sig { returns(T::Array[PDF::Reader::Reference]) }
767
+ sig { returns(T::Array[T.any(PDF::Reader::Reference, T::Hash[Symbol, T.untyped])]) }
723
768
  def page_references; end
724
769
 
725
770
  sig { returns(T::Boolean) }
@@ -749,41 +794,50 @@ module PDF
749
794
  sig { returns(T.untyped) }
750
795
  def object_streams; end
751
796
 
752
- sig { params(obj: T::Hash[T.untyped, T.untyped]).returns(T::Array[T::Hash[T.untyped, T.untyped]]) }
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])]) }
753
798
  def get_page_objects(obj); end
754
799
 
755
800
  sig { returns(Float) }
756
801
  def read_version; end
757
802
 
758
- sig { params(input: T.untyped).returns(IO) }
803
+ sig { params(input: T.any(IO, Tempfile, StringIO, String)).returns(T.any(IO, Tempfile, StringIO)) }
759
804
  def extract_io_from(input); end
760
805
 
761
- sig { params(input: T.untyped).returns(T.untyped) }
806
+ sig { params(input: String).returns(String) }
762
807
  def read_as_binary(input); end
763
808
  end
764
809
 
765
810
  class ObjectStream
766
- sig { params(stream: T.untyped).void }
767
- def initialize(stream); end
811
+ sig { params(stream: PDF::Reader::Stream).void }
812
+ def initialize(stream)
813
+ @dict = T.let(T.unsafe(nil), T::Hash[Symbol, T.untyped])
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))
817
+ end
768
818
 
769
- sig { params(objid: T.untyped).returns(T.untyped) }
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
+ }
770
824
  def [](objid); end
771
825
 
772
- sig { returns(T.untyped) }
826
+ sig { returns(Integer) }
773
827
  def size; end
774
828
 
775
- sig { returns(T.untyped) }
829
+ sig { returns(T::Hash[Integer, Integer]) }
776
830
  def offsets; end
777
831
 
778
- sig { returns(T.untyped) }
832
+ sig { returns(Integer) }
779
833
  def first; end
780
834
 
781
- sig { returns(T.untyped) }
835
+ sig { returns(PDF::Reader::Buffer) }
782
836
  def buffer; end
783
837
  end
784
838
 
785
839
  class OverlappingRunsFilter
786
- OVERLAPPING_THRESHOLD = 0.5
840
+ OVERLAPPING_THRESHOLD = T.let(T.unsafe(nil), Float)
787
841
 
788
842
  sig { params(runs: T::Array[PDF::Reader::TextRun]).returns(T::Array[PDF::Reader::TextRun]) }
789
843
  def self.exclude_redundant_runs(runs); end
@@ -792,6 +846,11 @@ module PDF
792
846
  def self.detect_intersection(sweep_line_status, event_point); end
793
847
  end
794
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
+
795
854
  class EventPoint
796
855
  sig { returns(Numeric) }
797
856
  attr_reader :x
@@ -800,26 +859,35 @@ module PDF
800
859
  attr_reader :run
801
860
 
802
861
  sig { params(x: Numeric, run: PDF::Reader::TextRun).void }
803
- def initialize(x, run); end
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
804
866
 
805
867
  sig { returns(T::Boolean) }
806
868
  def start?; end
807
869
  end
808
870
 
809
871
  class Page
810
- include ResourceMethods
811
-
812
872
  sig { returns(PDF::Reader::ObjectHash) }
813
873
  attr_reader :objects
814
874
 
815
- sig { returns(T.untyped) }
875
+ sig { returns(T::Hash[Symbol, T.untyped]) }
816
876
  attr_reader :page_object
817
877
 
818
- sig { returns(T.untyped) }
878
+ sig { returns(T.any(PDF::Reader::ObjectCache, T::Hash[T.untyped, T.untyped])) }
819
879
  attr_reader :cache
820
880
 
821
881
  sig { params(objects: PDF::Reader::ObjectHash, pagenum: Integer, options: T::Hash[Symbol, T.untyped]).void }
822
- def initialize(objects, pagenum, options = {}); end
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
823
891
 
824
892
  sig { returns(Integer) }
825
893
  def number; end
@@ -869,10 +937,10 @@ module PDF
869
937
  sig { returns(PDF::Reader::Resources) }
870
938
  def resources; end
871
939
 
872
- sig { params(receivers: T.untyped, instructions: T.untyped).returns(T.untyped) }
940
+ sig { params(receivers: T::Array[T.untyped], instructions: String).void }
873
941
  def content_stream(receivers, instructions); end
874
942
 
875
- sig { params(receivers: T.untyped, name: T.untyped, params: T.untyped).returns(T.untyped) }
943
+ sig { params(receivers: T::Array[Object], name: Symbol, params: T::Array[T.untyped]).void }
876
944
  def callback(receivers, name, params = []); end
877
945
 
878
946
  sig { returns(T.untyped) }
@@ -881,15 +949,26 @@ module PDF
881
949
  sig { params(origin: T.untyped).returns(T.untyped) }
882
950
  def ancestors(origin = @page_object[:Parent]); end
883
951
 
884
- sig { params(obj: T::Hash[T.untyped, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
952
+ sig { params(obj: T::Hash[Symbol, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
885
953
  def select_inheritable(obj); end
886
954
  end
887
955
 
888
956
  class PageLayout
889
- DEFAULT_FONT_SIZE = 12
957
+ DEFAULT_FONT_SIZE = T.let(T.unsafe(nil), Numeric)
890
958
 
891
959
  sig { params(runs: T::Array[PDF::Reader::TextRun], mediabox: T.any(T::Array[Numeric], PDF::Reader::Rectangle)).void }
892
- def initialize(runs, mediabox); end
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
893
972
 
894
973
  sig { returns(String) }
895
974
  def to_s; end
@@ -926,6 +1005,12 @@ module PDF
926
1005
 
927
1006
  sig { params(mediabox: T.untyped).returns(T.untyped) }
928
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
929
1014
  end
930
1015
 
931
1016
  class PageState
@@ -1110,81 +1195,7 @@ module PDF
1110
1195
  end
1111
1196
 
1112
1197
  class PagesStrategy
1113
- OPERATORS = {
1114
- 'b' => :close_fill_stroke,
1115
- 'B' => :fill_stroke,
1116
- 'b*' => :close_fill_stroke_with_even_odd,
1117
- 'B*' => :fill_stroke_with_even_odd,
1118
- 'BDC' => :begin_marked_content_with_pl,
1119
- 'BI' => :begin_inline_image,
1120
- 'BMC' => :begin_marked_content,
1121
- 'BT' => :begin_text_object,
1122
- 'BX' => :begin_compatibility_section,
1123
- 'c' => :append_curved_segment,
1124
- 'cm' => :concatenate_matrix,
1125
- 'CS' => :set_stroke_color_space,
1126
- 'cs' => :set_nonstroke_color_space,
1127
- 'd' => :set_line_dash,
1128
- 'd0' => :set_glyph_width,
1129
- 'd1' => :set_glyph_width_and_bounding_box,
1130
- 'Do' => :invoke_xobject,
1131
- 'DP' => :define_marked_content_with_pl,
1132
- 'EI' => :end_inline_image,
1133
- 'EMC' => :end_marked_content,
1134
- 'ET' => :end_text_object,
1135
- 'EX' => :end_compatibility_section,
1136
- 'f' => :fill_path_with_nonzero,
1137
- 'F' => :fill_path_with_nonzero,
1138
- 'f*' => :fill_path_with_even_odd,
1139
- 'G' => :set_gray_for_stroking,
1140
- 'g' => :set_gray_for_nonstroking,
1141
- 'gs' => :set_graphics_state_parameters,
1142
- 'h' => :close_subpath,
1143
- 'i' => :set_flatness_tolerance,
1144
- 'ID' => :begin_inline_image_data,
1145
- 'j' => :set_line_join_style,
1146
- 'J' => :set_line_cap_style,
1147
- 'K' => :set_cmyk_color_for_stroking,
1148
- 'k' => :set_cmyk_color_for_nonstroking,
1149
- 'l' => :append_line,
1150
- 'm' => :begin_new_subpath,
1151
- 'M' => :set_miter_limit,
1152
- 'MP' => :define_marked_content_point,
1153
- 'n' => :end_path,
1154
- 'q' => :save_graphics_state,
1155
- 'Q' => :restore_graphics_state,
1156
- 're' => :append_rectangle,
1157
- 'RG' => :set_rgb_color_for_stroking,
1158
- 'rg' => :set_rgb_color_for_nonstroking,
1159
- 'ri' => :set_color_rendering_intent,
1160
- 's' => :close_and_stroke_path,
1161
- 'S' => :stroke_path,
1162
- 'SC' => :set_color_for_stroking,
1163
- 'sc' => :set_color_for_nonstroking,
1164
- 'SCN' => :set_color_for_stroking_and_special,
1165
- 'scn' => :set_color_for_nonstroking_and_special,
1166
- 'sh' => :paint_area_with_shading_pattern,
1167
- 'T*' => :move_to_start_of_next_line,
1168
- 'Tc' => :set_character_spacing,
1169
- 'Td' => :move_text_position,
1170
- 'TD' => :move_text_position_and_set_leading,
1171
- 'Tf' => :set_text_font_and_size,
1172
- 'Tj' => :show_text,
1173
- 'TJ' => :show_text_with_positioning,
1174
- 'TL' => :set_text_leading,
1175
- 'Tm' => :set_text_matrix_and_text_line_matrix,
1176
- 'Tr' => :set_text_rendering_mode,
1177
- 'Ts' => :set_text_rise,
1178
- 'Tw' => :set_word_spacing,
1179
- 'Tz' => :set_horizontal_text_scaling,
1180
- 'v' => :append_curved_segment_initial_point_replicated,
1181
- 'w' => :set_line_width,
1182
- 'W' => :set_clipping_path_with_nonzero,
1183
- 'W*' => :set_clipping_path_with_even_odd,
1184
- 'y' => :append_curved_segment_final_point_replicated,
1185
- '\'' => :move_to_next_line_and_show_text,
1186
- '"' => :set_spacing_next_line_show_text,
1187
- }
1198
+ OPERATORS = T.let(T.unsafe(nil), T::Hash[String, Symbol])
1188
1199
  end
1189
1200
 
1190
1201
  class Parser
@@ -1332,25 +1343,28 @@ module PDF
1332
1343
  end
1333
1344
 
1334
1345
  class Reference
1335
- sig { returns(T.untyped) }
1346
+ sig { returns(Integer) }
1336
1347
  attr_reader :id
1337
1348
 
1338
- sig { returns(T.untyped) }
1349
+ sig { returns(Integer) }
1339
1350
  attr_reader :gen
1340
1351
 
1341
- sig { params(id: T.untyped, gen: T.untyped).void }
1342
- def initialize(id, gen); end
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
1343
1357
 
1344
- sig { returns(T.untyped) }
1358
+ sig { returns(T::Array[PDF::Reader::Reference]) }
1345
1359
  def to_a; end
1346
1360
 
1347
- sig { returns(T.untyped) }
1361
+ sig { returns(Integer) }
1348
1362
  def to_i; end
1349
1363
 
1350
- sig { params(obj: T.untyped).returns(T.untyped) }
1364
+ sig { params(obj: Object).returns(T::Boolean) }
1351
1365
  def ==(obj); end
1352
1366
 
1353
- sig { returns(T.untyped) }
1367
+ sig { returns(Integer) }
1354
1368
  def hash; end
1355
1369
  end
1356
1370
 
@@ -1386,31 +1400,36 @@ module PDF
1386
1400
  def series(*methods); end
1387
1401
  end
1388
1402
 
1389
- module ResourceMethods
1390
- extend T::Helpers
1403
+ class Resources
1391
1404
 
1392
- sig { returns(T.untyped) }
1405
+ sig { params(objects: PDF::Reader::ObjectHash, resources: T::Hash[T.untyped, T.untyped]).void }
1406
+ def initialize(objects, resources)
1407
+ @objects = T.let(T.unsafe(nil), PDF::Reader::ObjectHash)
1408
+ @resources = T.let(T.unsafe(nil), T::Hash[Symbol, T.untyped])
1409
+ end
1410
+
1411
+ sig { returns(T::Hash[Symbol, T.untyped]) }
1393
1412
  def color_spaces; end
1394
1413
 
1395
- sig { returns(T::Hash[T.untyped, T.untyped]) }
1414
+ sig { returns(T::Hash[Symbol, T.untyped]) }
1396
1415
  def fonts; end
1397
1416
 
1398
- sig { returns(T.untyped) }
1417
+ sig { returns(T::Hash[Symbol, T.untyped]) }
1399
1418
  def graphic_states; end
1400
1419
 
1401
- sig { returns(T.untyped) }
1420
+ sig { returns(T::Hash[Symbol, T.untyped]) }
1402
1421
  def patterns; end
1403
1422
 
1404
- sig { returns(T.untyped) }
1423
+ sig { returns(T::Array[Symbol]) }
1405
1424
  def procedure_sets; end
1406
1425
 
1407
- sig { returns(T.untyped) }
1426
+ sig { returns(T::Hash[Symbol, T.untyped]) }
1408
1427
  def properties; end
1409
1428
 
1410
- sig { returns(T.untyped) }
1429
+ sig { returns(T::Hash[Symbol, T.untyped]) }
1411
1430
  def shadings; end
1412
1431
 
1413
- sig { returns(T.untyped) }
1432
+ sig { returns(T::Hash[Symbol, PDF::Reader::Stream]) }
1414
1433
  def xobjects; end
1415
1434
  end
1416
1435
 
@@ -1479,54 +1498,68 @@ module PDF
1479
1498
 
1480
1499
  class SynchronizedCache
1481
1500
  sig { void }
1482
- def initialize; end
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
1483
1505
 
1484
- sig { params(key: T.untyped).returns(T.untyped) }
1506
+ sig { params(key: Object).returns(T.untyped) }
1485
1507
  def [](key); end
1486
1508
 
1487
- sig { params(key: T.untyped, value: T.untyped).returns(T.untyped) }
1509
+ sig { params(key: Object, value: T.nilable(Object)).returns(T.untyped) }
1488
1510
  def []=(key, value); end
1489
1511
  end
1490
1512
 
1491
1513
  class TextRun
1492
1514
  include Comparable
1493
1515
 
1494
- sig { returns(T.untyped) }
1495
- attr_reader :x
1496
-
1497
- sig { returns(T.untyped) }
1498
- attr_reader :y
1499
-
1500
- sig { returns(T.untyped) }
1516
+ sig { returns(Numeric) }
1501
1517
  attr_reader :width
1502
1518
 
1503
- sig { returns(T.untyped) }
1519
+ sig { returns(Numeric) }
1504
1520
  attr_reader :font_size
1505
1521
 
1506
- sig { returns(T.untyped) }
1522
+ sig { returns(String) }
1507
1523
  attr_reader :text
1508
1524
 
1525
+ sig { returns(PDF::Reader::Point) }
1526
+ attr_reader :origin
1527
+
1509
1528
  sig do
1510
1529
  params(
1511
- x: T.untyped,
1512
- y: T.untyped,
1513
- width: T.untyped,
1514
- font_size: T.untyped,
1515
- text: T.untyped
1530
+ x: Numeric,
1531
+ y: Numeric,
1532
+ width: Numeric,
1533
+ font_size: Numeric,
1534
+ text: String
1516
1535
  ).void
1517
1536
  end
1518
- def initialize(x, y, width, font_size, text); end
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
1519
1546
 
1520
1547
  sig { params(other: T.untyped).returns(T.untyped) }
1521
1548
  def <=>(other); end
1522
1549
 
1523
- sig { returns(T.untyped) }
1550
+ sig { returns(Numeric) }
1524
1551
  def endx; end
1525
1552
 
1526
- sig { returns(T.untyped) }
1553
+ sig { returns(Numeric) }
1527
1554
  def endy; end
1528
1555
 
1529
- sig { returns(T.untyped) }
1556
+ sig { returns(Numeric) }
1557
+ def x; end
1558
+
1559
+ sig { returns(Numeric) }
1560
+ def y; end
1561
+
1562
+ sig { returns(Numeric) }
1530
1563
  def mean_character_width; end
1531
1564
 
1532
1565
  sig { params(other: PDF::Reader::TextRun).returns(T::Boolean) }
@@ -1535,22 +1568,22 @@ module PDF
1535
1568
  sig { params(other: PDF::Reader::TextRun).returns(PDF::Reader::TextRun) }
1536
1569
  def +(other); end
1537
1570
 
1538
- sig { returns(T.untyped) }
1571
+ sig { returns(String) }
1539
1572
  def inspect; end
1540
1573
 
1541
- sig { params(other_run: T.untyped).returns(T.untyped) }
1574
+ sig { params(other_run: T.untyped).returns(T::Boolean) }
1542
1575
  def intersect?(other_run); end
1543
1576
 
1544
- sig { params(other_run: T.untyped).returns(T.untyped) }
1577
+ sig { params(other_run: T.untyped).returns(Numeric) }
1545
1578
  def intersection_area_percent(other_run); end
1546
1579
 
1547
- sig { returns(T.untyped) }
1580
+ sig { returns(Numeric) }
1548
1581
  def area; end
1549
1582
 
1550
- sig { returns(T.untyped) }
1583
+ sig { returns(T::Range[Numeric]) }
1551
1584
  def mergable_range; end
1552
1585
 
1553
- sig { returns(T.untyped) }
1586
+ sig { returns(Numeric) }
1554
1587
  def character_count; end
1555
1588
  end
1556
1589
 
@@ -1560,120 +1593,130 @@ module PDF
1560
1593
  end
1561
1594
 
1562
1595
  class TransformationMatrix
1563
- sig { returns(T.untyped) }
1596
+ sig { returns(Numeric) }
1564
1597
  attr_reader :a
1565
1598
 
1566
- sig { returns(T.untyped) }
1599
+ sig { returns(Numeric) }
1567
1600
  attr_reader :b
1568
1601
 
1569
- sig { returns(T.untyped) }
1602
+ sig { returns(Numeric) }
1570
1603
  attr_reader :c
1571
1604
 
1572
- sig { returns(T.untyped) }
1605
+ sig { returns(Numeric) }
1573
1606
  attr_reader :d
1574
1607
 
1575
- sig { returns(T.untyped) }
1608
+ sig { returns(Numeric) }
1576
1609
  attr_reader :e
1577
1610
 
1578
- sig { returns(T.untyped) }
1611
+ sig { returns(Numeric) }
1579
1612
  attr_reader :f
1580
1613
 
1581
1614
  sig do
1582
1615
  params(
1583
- a: T.untyped,
1584
- b: T.untyped,
1585
- c: T.untyped,
1586
- d: T.untyped,
1587
- e: T.untyped,
1588
- f: T.untyped
1616
+ a: Numeric,
1617
+ b: Numeric,
1618
+ c: Numeric,
1619
+ d: Numeric,
1620
+ e: Numeric,
1621
+ f: Numeric
1589
1622
  ).void
1590
1623
  end
1591
- def initialize(a, b, c, d, e, f); end
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
1592
1632
 
1593
- sig { returns(T.untyped) }
1633
+ sig { returns(String) }
1594
1634
  def inspect; end
1595
1635
 
1596
- sig { returns(T.untyped) }
1636
+ sig { returns(T::Array[Numeric]) }
1597
1637
  def to_a; end
1598
1638
 
1599
1639
  sig do
1600
1640
  params(
1601
- a: T.untyped,
1602
- b: T.untyped,
1603
- c: T.untyped,
1604
- d: T.untyped,
1605
- e: T.untyped,
1606
- f: T.untyped
1607
- ).returns(T.untyped)
1641
+ a: Numeric,
1642
+ b: Numeric,
1643
+ c: Numeric,
1644
+ d: Numeric,
1645
+ e: Numeric,
1646
+ f: Numeric
1647
+ ).returns(PDF::Reader::TransformationMatrix)
1608
1648
  end
1609
- def multiply!(a, b = nil, c = nil, d = nil, e = nil, f = nil); end
1649
+ def multiply!(a, b, c, d, e, f); end
1610
1650
 
1611
- sig { params(e2: T.untyped).returns(T.untyped) }
1651
+ sig { params(e2: Numeric).void }
1612
1652
  def horizontal_displacement_multiply!(e2); end
1613
1653
 
1614
1654
  sig do
1615
1655
  params(
1616
- a2: T.untyped,
1617
- b2: T.untyped,
1618
- c2: T.untyped,
1619
- d2: T.untyped,
1620
- e2: T.untyped,
1621
- f2: T.untyped
1622
- ).returns(T.untyped)
1656
+ a2: Numeric,
1657
+ b2: Numeric,
1658
+ c2: Numeric,
1659
+ d2: Numeric,
1660
+ e2: Numeric,
1661
+ f2: Numeric
1662
+ ).void
1623
1663
  end
1624
1664
  def horizontal_displacement_multiply_reversed!(a2, b2, c2, d2, e2, f2); end
1625
1665
 
1626
1666
  sig do
1627
1667
  params(
1628
- a2: T.untyped,
1629
- b2: T.untyped,
1630
- c2: T.untyped,
1631
- d2: T.untyped,
1632
- e2: T.untyped,
1633
- f2: T.untyped
1634
- ).returns(T.untyped)
1668
+ a2: Numeric,
1669
+ b2: Numeric,
1670
+ c2: Numeric,
1671
+ d2: Numeric,
1672
+ e2: Numeric,
1673
+ f2: Numeric
1674
+ ).void
1635
1675
  end
1636
1676
  def xy_scaling_multiply!(a2, b2, c2, d2, e2, f2); end
1637
1677
 
1638
1678
  sig do
1639
1679
  params(
1640
- a2: T.untyped,
1641
- b2: T.untyped,
1642
- c2: T.untyped,
1643
- d2: T.untyped,
1644
- e2: T.untyped,
1645
- f2: T.untyped
1646
- ).returns(T.untyped)
1680
+ a2: Numeric,
1681
+ b2: Numeric,
1682
+ c2: Numeric,
1683
+ d2: Numeric,
1684
+ e2: Numeric,
1685
+ f2: Numeric
1686
+ ).void
1647
1687
  end
1648
1688
  def xy_scaling_multiply_reversed!(a2, b2, c2, d2, e2, f2); end
1649
1689
 
1650
1690
  sig do
1651
1691
  params(
1652
- a2: T.untyped,
1653
- b2: T.untyped,
1654
- c2: T.untyped,
1655
- d2: T.untyped,
1656
- e2: T.untyped,
1657
- f2: T.untyped
1658
- ).returns(T.untyped)
1692
+ a2: Numeric,
1693
+ b2: Numeric,
1694
+ c2: Numeric,
1695
+ d2: Numeric,
1696
+ e2: Numeric,
1697
+ f2: Numeric
1698
+ ).void
1659
1699
  end
1660
1700
  def regular_multiply!(a2, b2, c2, d2, e2, f2); end
1661
1701
 
1662
1702
  sig do
1663
1703
  params(
1664
- a2: T.untyped,
1665
- b2: T.untyped,
1666
- c2: T.untyped,
1667
- d2: T.untyped,
1668
- e2: T.untyped,
1669
- f2: T.untyped
1670
- ).returns(T.untyped)
1704
+ a2: Numeric,
1705
+ b2: Numeric,
1706
+ c2: Numeric,
1707
+ d2: Numeric,
1708
+ e2: Numeric,
1709
+ f2: Numeric
1710
+ ).void
1671
1711
  end
1672
1712
  def faster_multiply!(a2, b2, c2, d2, e2, f2); end
1673
1713
  end
1674
1714
 
1675
1715
  class TypeCheck
1676
1716
 
1717
+ sig { params(obj: T.untyped).returns(Integer) }
1718
+ def self.cast_to_int!(obj); end
1719
+
1677
1720
  sig { params(obj: T.untyped).returns(Numeric) }
1678
1721
  def self.cast_to_numeric!(obj); end
1679
1722
 
@@ -1682,6 +1725,15 @@ module PDF
1682
1725
 
1683
1726
  sig { params(obj: T.untyped).returns(T.nilable(Symbol)) }
1684
1727
  def self.cast_to_symbol(obj); end
1728
+
1729
+ sig { params(obj: T.untyped).returns(Symbol) }
1730
+ def self.cast_to_symbol!(obj); end
1731
+
1732
+ sig { params(obj: T.untyped).returns(T::Hash[Symbol, T.untyped]) }
1733
+ def self.cast_to_pdf_dict!(obj); end
1734
+
1735
+ sig { params(obj: T.untyped).returns(T::Hash[Symbol, PDF::Reader::Stream]) }
1736
+ def self.cast_to_pdf_dict_with_stream_values!(obj); end
1685
1737
  end
1686
1738
 
1687
1739
  class ValidatingReceiver
@@ -1785,12 +1837,18 @@ module PDF
1785
1837
 
1786
1838
  class XRef
1787
1839
  include Enumerable
1840
+ extend T::Generic # Provides `type_member` helper
1788
1841
 
1789
- sig { returns(T.untyped) }
1842
+ sig { returns(T::Hash[Symbol, T.untyped]) }
1790
1843
  attr_reader :trailer
1791
1844
 
1792
- sig { params(io: T.untyped).void }
1793
- def initialize(io); end
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
1794
1852
 
1795
1853
  sig { returns(T.untyped) }
1796
1854
  def size; end
@@ -1854,7 +1912,9 @@ module PDF
1854
1912
 
1855
1913
  class Depredict
1856
1914
  sig { params(options: T::Hash[T.untyped, T.untyped]).void }
1857
- def initialize(options = {}); end
1915
+ def initialize(options = {})
1916
+ @options = T.let(T.unsafe(nil), T::Hash[T.untyped, T.untyped])
1917
+ end
1858
1918
 
1859
1919
  sig { params(data: String).returns(String) }
1860
1920
  def filter(data); end
@@ -1915,62 +1975,72 @@ module PDF
1915
1975
 
1916
1976
  module WidthCalculator
1917
1977
  class BuiltIn
1918
- BUILTINS = [
1919
- :Courier, :"Courier-Bold", :"Courier-BoldOblique", :"Courier-Oblique",
1920
- :Helvetica, :"Helvetica-Bold", :"Helvetica-BoldOblique", :"Helvetica-Oblique",
1921
- :Symbol,
1922
- :"Times-Roman", :"Times-Bold", :"Times-BoldItalic", :"Times-Italic",
1923
- :ZapfDingbats
1924
- ]
1925
-
1926
- sig { params(font: T.untyped).void }
1927
- def initialize(font); end
1928
-
1929
- sig { params(code_point: T.untyped).returns(T.untyped) }
1978
+ BUILTINS = T.let(T.unsafe(nil), T::Array[Symbol])
1979
+
1980
+ @@all_metrics = T.let(T.unsafe(nil), T.nilable(PDF::Reader::SynchronizedCache))
1981
+
1982
+ sig { params(font: PDF::Reader::Font).void }
1983
+ def initialize(font)
1984
+ @font = T.let(T.unsafe(nil), PDF::Reader::Font)
1985
+ @metrics = T.let(T.unsafe(nil), AFM::Font)
1986
+ end
1987
+
1988
+ sig { params(code_point: T.nilable(Integer)).returns(Numeric) }
1930
1989
  def glyph_width(code_point); end
1931
1990
 
1932
- sig { params(code_point: T.untyped).returns(T.untyped) }
1991
+ sig { params(code_point: Integer).returns(T::Boolean) }
1933
1992
  def control_character?(code_point); end
1934
1993
 
1935
- sig { params(font_name: T.untyped).returns(T.untyped) }
1994
+ sig { params(font_name: T.nilable(Symbol)).returns(String) }
1936
1995
  def extract_basefont(font_name); end
1937
1996
  end
1938
1997
 
1939
1998
  class Composite
1940
- sig { params(font: T.untyped).void }
1941
- def initialize(font); end
1999
+ sig { params(font: PDF::Reader::Font).void }
2000
+ def initialize(font)
2001
+ @font = T.let(T.unsafe(nil), PDF::Reader::Font)
2002
+ @widths = T.let(T.unsafe(nil), PDF::Reader::CidWidths)
2003
+ end
1942
2004
 
1943
- sig { params(code_point: T.untyped).returns(T.untyped) }
2005
+ sig { params(code_point: T.nilable(Integer)).returns(Numeric) }
1944
2006
  def glyph_width(code_point); end
1945
2007
  end
1946
2008
 
1947
2009
  class TrueType
1948
- sig { params(font: T.untyped).void }
1949
- def initialize(font); end
2010
+ sig { params(font: PDF::Reader::Font).void }
2011
+ def initialize(font)
2012
+ @font = T.let(T.unsafe(nil), PDF::Reader::Font)
2013
+ @missing_width = T.let(T.unsafe(nil), Numeric)
2014
+ end
1950
2015
 
1951
- sig { params(code_point: T.untyped).returns(T.untyped) }
2016
+ sig { params(code_point: T.nilable(Integer)).returns(Numeric) }
1952
2017
  def glyph_width(code_point); end
1953
2018
 
1954
- sig { params(code_point: T.untyped).returns(T.untyped) }
2019
+ sig { params(code_point: Integer).returns(T.nilable(Numeric)) }
1955
2020
  def glyph_width_from_font(code_point); end
1956
2021
 
1957
- sig { params(code_point: T.untyped).returns(T.untyped) }
2022
+ sig { params(code_point: Integer).returns(T.nilable(Numeric)) }
1958
2023
  def glyph_width_from_descriptor(code_point); end
1959
2024
  end
1960
2025
 
1961
2026
  class TypeOneOrThree
1962
- sig { params(font: T.untyped).void }
1963
- def initialize(font); end
2027
+ sig { params(font: PDF::Reader::Font).void }
2028
+ def initialize(font)
2029
+ @font = T.let(T.unsafe(nil), PDF::Reader::Font)
2030
+ @missing_width = T.let(T.unsafe(nil), Numeric)
2031
+ end
1964
2032
 
1965
- sig { params(code_point: T.untyped).returns(T.untyped) }
2033
+ sig { params(code_point: T.nilable(Integer)).returns(Numeric) }
1966
2034
  def glyph_width(code_point); end
1967
2035
  end
1968
2036
 
1969
2037
  class TypeZero
1970
- sig { params(font: T.untyped).void }
1971
- def initialize(font); end
2038
+ sig { params(font: PDF::Reader::Font).void }
2039
+ def initialize(font)
2040
+ @font = T.let(T.unsafe(nil), PDF::Reader::Font)
2041
+ end
1972
2042
 
1973
- sig { params(code_point: T.untyped).returns(T.untyped) }
2043
+ sig { params(code_point: T.nilable(Integer)).returns(Numeric) }
1974
2044
  def glyph_width(code_point); end
1975
2045
  end
1976
2046
  end