pdf-reader 2.6.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +21 -1
  3. data/Rakefile +1 -1
  4. data/examples/rspec.rb +1 -0
  5. data/lib/pdf/reader/bounding_rectangle_runs_filter.rb +16 -0
  6. data/lib/pdf/reader/buffer.rb +1 -0
  7. data/lib/pdf/reader/cid_widths.rb +1 -0
  8. data/lib/pdf/reader/cmap.rb +5 -3
  9. data/lib/pdf/reader/encoding.rb +2 -1
  10. data/lib/pdf/reader/error.rb +8 -0
  11. data/lib/pdf/reader/filter/ascii85.rb +2 -0
  12. data/lib/pdf/reader/filter/ascii_hex.rb +6 -1
  13. data/lib/pdf/reader/filter/depredict.rb +7 -5
  14. data/lib/pdf/reader/filter/flate.rb +2 -0
  15. data/lib/pdf/reader/filter/lzw.rb +2 -0
  16. data/lib/pdf/reader/filter/null.rb +1 -0
  17. data/lib/pdf/reader/filter/run_length.rb +19 -13
  18. data/lib/pdf/reader/filter.rb +1 -0
  19. data/lib/pdf/reader/font.rb +44 -0
  20. data/lib/pdf/reader/font_descriptor.rb +1 -0
  21. data/lib/pdf/reader/form_xobject.rb +1 -0
  22. data/lib/pdf/reader/glyph_hash.rb +1 -0
  23. data/lib/pdf/reader/lzw.rb +4 -2
  24. data/lib/pdf/reader/null_security_handler.rb +1 -0
  25. data/lib/pdf/reader/object_cache.rb +1 -0
  26. data/lib/pdf/reader/object_hash.rb +5 -2
  27. data/lib/pdf/reader/object_stream.rb +1 -0
  28. data/lib/pdf/reader/overlapping_runs_filter.rb +11 -4
  29. data/lib/pdf/reader/page.rb +73 -11
  30. data/lib/pdf/reader/page_layout.rb +28 -32
  31. data/lib/pdf/reader/page_state.rb +11 -10
  32. data/lib/pdf/reader/page_text_receiver.rb +53 -9
  33. data/lib/pdf/reader/pages_strategy.rb +1 -0
  34. data/lib/pdf/reader/parser.rb +7 -1
  35. data/lib/pdf/reader/point.rb +25 -0
  36. data/lib/pdf/reader/print_receiver.rb +1 -0
  37. data/lib/pdf/reader/rectangle.rb +113 -0
  38. data/lib/pdf/reader/reference.rb +1 -0
  39. data/lib/pdf/reader/register_receiver.rb +1 -0
  40. data/lib/pdf/reader/resource_methods.rb +5 -0
  41. data/lib/pdf/reader/standard_security_handler.rb +1 -0
  42. data/lib/pdf/reader/standard_security_handler_v5.rb +1 -0
  43. data/lib/pdf/reader/stream.rb +1 -0
  44. data/lib/pdf/reader/synchronized_cache.rb +1 -0
  45. data/lib/pdf/reader/text_run.rb +14 -6
  46. data/lib/pdf/reader/token.rb +1 -0
  47. data/lib/pdf/reader/transformation_matrix.rb +1 -0
  48. data/lib/pdf/reader/unimplemented_security_handler.rb +1 -0
  49. data/lib/pdf/reader/width_calculator/built_in.rb +1 -0
  50. data/lib/pdf/reader/width_calculator/composite.rb +1 -0
  51. data/lib/pdf/reader/width_calculator/true_type.rb +1 -0
  52. data/lib/pdf/reader/width_calculator/type_one_or_three.rb +1 -0
  53. data/lib/pdf/reader/width_calculator/type_zero.rb +1 -0
  54. data/lib/pdf/reader/width_calculator.rb +1 -0
  55. data/lib/pdf/reader/xref.rb +1 -0
  56. data/lib/pdf/reader/zero_width_runs_filter.rb +2 -0
  57. data/lib/pdf/reader.rb +29 -6
  58. data/lib/pdf-reader.rb +1 -0
  59. data/rbi/pdf-reader.rbi +1763 -0
  60. metadata +13 -10
  61. data/lib/pdf/reader/orientation_detector.rb +0 -34
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf-reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Healy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-12 00:00:00.000000000 Z
11
+ date: 2021-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -215,6 +215,7 @@ files:
215
215
  - lib/pdf/reader/afm/Times-Italic.afm
216
216
  - lib/pdf/reader/afm/Times-Roman.afm
217
217
  - lib/pdf/reader/afm/ZapfDingbats.afm
218
+ - lib/pdf/reader/bounding_rectangle_runs_filter.rb
218
219
  - lib/pdf/reader/buffer.rb
219
220
  - lib/pdf/reader/cid_widths.rb
220
221
  - lib/pdf/reader/cmap.rb
@@ -246,7 +247,6 @@ files:
246
247
  - lib/pdf/reader/object_cache.rb
247
248
  - lib/pdf/reader/object_hash.rb
248
249
  - lib/pdf/reader/object_stream.rb
249
- - lib/pdf/reader/orientation_detector.rb
250
250
  - lib/pdf/reader/overlapping_runs_filter.rb
251
251
  - lib/pdf/reader/page.rb
252
252
  - lib/pdf/reader/page_layout.rb
@@ -254,7 +254,9 @@ files:
254
254
  - lib/pdf/reader/page_text_receiver.rb
255
255
  - lib/pdf/reader/pages_strategy.rb
256
256
  - lib/pdf/reader/parser.rb
257
+ - lib/pdf/reader/point.rb
257
258
  - lib/pdf/reader/print_receiver.rb
259
+ - lib/pdf/reader/rectangle.rb
258
260
  - lib/pdf/reader/reference.rb
259
261
  - lib/pdf/reader/register_receiver.rb
260
262
  - lib/pdf/reader/resource_methods.rb
@@ -274,15 +276,16 @@ files:
274
276
  - lib/pdf/reader/width_calculator/type_zero.rb
275
277
  - lib/pdf/reader/xref.rb
276
278
  - lib/pdf/reader/zero_width_runs_filter.rb
279
+ - rbi/pdf-reader.rbi
277
280
  homepage: https://github.com/yob/pdf-reader
278
281
  licenses:
279
282
  - MIT
280
283
  metadata:
281
284
  bug_tracker_uri: https://github.com/yob/pdf-reader/issues
282
- changelog_uri: https://github.com/yob/pdf-reader/blob/v2.6.0/CHANGELOG
283
- documentation_uri: https://www.rubydoc.info/gems/pdf-reader/2.6.0
284
- source_code_uri: https://github.com/yob/pdf-reader/tree/v2.6.0
285
- post_install_message:
285
+ changelog_uri: https://github.com/yob/pdf-reader/blob/v2.8.0/CHANGELOG
286
+ documentation_uri: https://www.rubydoc.info/gems/pdf-reader/2.8.0
287
+ source_code_uri: https://github.com/yob/pdf-reader/tree/v2.8.0
288
+ post_install_message:
286
289
  rdoc_options:
287
290
  - "--title"
288
291
  - PDF::Reader Documentation
@@ -302,8 +305,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
305
  - !ruby/object:Gem::Version
303
306
  version: '0'
304
307
  requirements: []
305
- rubygems_version: 3.1.4
306
- signing_key:
308
+ rubygems_version: 3.2.3
309
+ signing_key:
307
310
  specification_version: 4
308
311
  summary: A library for accessing the content of PDF files
309
312
  test_files: []
@@ -1,34 +0,0 @@
1
- # coding: utf-8
2
- # frozen_string_literal: true
3
-
4
- class PDF::Reader
5
- # Small util class for detecting the orientation of a single PDF page. Accounts
6
- # for any page rotation that is in place.
7
- #
8
- # OrientationDetector.new(:MediaBox => [0,0,612,792]).orientation
9
- # => "portrait"
10
- #
11
- class OrientationDetector
12
- def initialize(attributes)
13
- @attributes = attributes
14
- end
15
-
16
- def orientation
17
- @orientation ||= detect_orientation
18
- end
19
-
20
- private
21
-
22
- def detect_orientation
23
- llx,lly,urx,ury = @attributes[:MediaBox]
24
- rotation = @attributes[:Rotate].to_i
25
- width = (urx.to_i - llx.to_i).abs
26
- height = (ury.to_i - lly.to_i).abs
27
- if width > height
28
- (rotation % 180).zero? ? 'landscape' : 'portrait'
29
- else
30
- (rotation % 180).zero? ? 'portrait' : 'landscape'
31
- end
32
- end
33
- end
34
- end