pdf-reader 2.4.1 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +40 -0
  3. data/README.md +16 -1
  4. data/Rakefile +1 -1
  5. data/examples/extract_fonts.rb +12 -7
  6. data/examples/rspec.rb +1 -0
  7. data/lib/pdf/reader/buffer.rb +63 -21
  8. data/lib/pdf/reader/cid_widths.rb +1 -0
  9. data/lib/pdf/reader/cmap.rb +5 -3
  10. data/lib/pdf/reader/encoding.rb +3 -2
  11. data/lib/pdf/reader/error.rb +11 -3
  12. data/lib/pdf/reader/filter/ascii85.rb +7 -1
  13. data/lib/pdf/reader/filter/ascii_hex.rb +6 -1
  14. data/lib/pdf/reader/filter/depredict.rb +10 -8
  15. data/lib/pdf/reader/filter/flate.rb +27 -14
  16. data/lib/pdf/reader/filter/lzw.rb +2 -0
  17. data/lib/pdf/reader/filter/null.rb +1 -0
  18. data/lib/pdf/reader/filter/run_length.rb +19 -13
  19. data/lib/pdf/reader/filter.rb +1 -0
  20. data/lib/pdf/reader/font.rb +1 -0
  21. data/lib/pdf/reader/font_descriptor.rb +1 -0
  22. data/lib/pdf/reader/form_xobject.rb +1 -0
  23. data/lib/pdf/reader/glyph_hash.rb +16 -9
  24. data/lib/pdf/reader/glyphlist-zapfdingbats.txt +245 -0
  25. data/lib/pdf/reader/lzw.rb +4 -2
  26. data/lib/pdf/reader/null_security_handler.rb +1 -0
  27. data/lib/pdf/reader/object_cache.rb +1 -0
  28. data/lib/pdf/reader/object_hash.rb +8 -3
  29. data/lib/pdf/reader/object_stream.rb +1 -0
  30. data/lib/pdf/reader/overlapping_runs_filter.rb +11 -4
  31. data/lib/pdf/reader/page.rb +60 -9
  32. data/lib/pdf/reader/page_layout.rb +37 -23
  33. data/lib/pdf/reader/page_state.rb +18 -23
  34. data/lib/pdf/reader/page_text_receiver.rb +28 -5
  35. data/lib/pdf/reader/pages_strategy.rb +1 -0
  36. data/lib/pdf/reader/parser.rb +12 -7
  37. data/lib/pdf/reader/point.rb +25 -0
  38. data/lib/pdf/reader/print_receiver.rb +1 -0
  39. data/lib/pdf/reader/rectangle.rb +95 -0
  40. data/lib/pdf/reader/reference.rb +1 -0
  41. data/lib/pdf/reader/register_receiver.rb +1 -0
  42. data/lib/pdf/reader/resource_methods.rb +5 -0
  43. data/lib/pdf/reader/standard_security_handler.rb +1 -0
  44. data/lib/pdf/reader/standard_security_handler_v5.rb +1 -0
  45. data/lib/pdf/reader/stream.rb +1 -0
  46. data/lib/pdf/reader/synchronized_cache.rb +1 -0
  47. data/lib/pdf/reader/text_run.rb +1 -0
  48. data/lib/pdf/reader/token.rb +1 -0
  49. data/lib/pdf/reader/transformation_matrix.rb +1 -0
  50. data/lib/pdf/reader/unimplemented_security_handler.rb +1 -0
  51. data/lib/pdf/reader/width_calculator/built_in.rb +8 -15
  52. data/lib/pdf/reader/width_calculator/composite.rb +1 -0
  53. data/lib/pdf/reader/width_calculator/true_type.rb +1 -0
  54. data/lib/pdf/reader/width_calculator/type_one_or_three.rb +1 -0
  55. data/lib/pdf/reader/width_calculator/type_zero.rb +1 -0
  56. data/lib/pdf/reader/width_calculator.rb +1 -0
  57. data/lib/pdf/reader/xref.rb +7 -1
  58. data/lib/pdf/reader/zero_width_runs_filter.rb +13 -0
  59. data/lib/pdf/reader.rb +14 -4
  60. data/lib/pdf-reader.rb +1 -0
  61. data/rbi/pdf-reader.rbi +1744 -0
  62. metadata +17 -13
  63. 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.4.1
4
+ version: 2.7.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: 2020-09-24 00:00:00.000000000 Z
11
+ date: 2021-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.0.0
103
+ version: '1.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.0
110
+ version: '1.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: ruby-rc4
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -239,13 +239,13 @@ files:
239
239
  - lib/pdf/reader/font_descriptor.rb
240
240
  - lib/pdf/reader/form_xobject.rb
241
241
  - lib/pdf/reader/glyph_hash.rb
242
+ - lib/pdf/reader/glyphlist-zapfdingbats.txt
242
243
  - lib/pdf/reader/glyphlist.txt
243
244
  - lib/pdf/reader/lzw.rb
244
245
  - lib/pdf/reader/null_security_handler.rb
245
246
  - lib/pdf/reader/object_cache.rb
246
247
  - lib/pdf/reader/object_hash.rb
247
248
  - lib/pdf/reader/object_stream.rb
248
- - lib/pdf/reader/orientation_detector.rb
249
249
  - lib/pdf/reader/overlapping_runs_filter.rb
250
250
  - lib/pdf/reader/page.rb
251
251
  - lib/pdf/reader/page_layout.rb
@@ -253,7 +253,9 @@ files:
253
253
  - lib/pdf/reader/page_text_receiver.rb
254
254
  - lib/pdf/reader/pages_strategy.rb
255
255
  - lib/pdf/reader/parser.rb
256
+ - lib/pdf/reader/point.rb
256
257
  - lib/pdf/reader/print_receiver.rb
258
+ - lib/pdf/reader/rectangle.rb
257
259
  - lib/pdf/reader/reference.rb
258
260
  - lib/pdf/reader/register_receiver.rb
259
261
  - lib/pdf/reader/resource_methods.rb
@@ -272,15 +274,17 @@ files:
272
274
  - lib/pdf/reader/width_calculator/type_one_or_three.rb
273
275
  - lib/pdf/reader/width_calculator/type_zero.rb
274
276
  - lib/pdf/reader/xref.rb
277
+ - lib/pdf/reader/zero_width_runs_filter.rb
278
+ - rbi/pdf-reader.rbi
275
279
  homepage: https://github.com/yob/pdf-reader
276
280
  licenses:
277
281
  - MIT
278
282
  metadata:
279
283
  bug_tracker_uri: https://github.com/yob/pdf-reader/issues
280
- changelog_uri: https://github.com/yob/pdf-reader/blob/v2.4.1/CHANGELOG
281
- documentation_uri: https://www.rubydoc.info/gems/pdf-reader/2.4.1
282
- source_code_uri: https://github.com/yob/pdf-reader/tree/v2.4.1
283
- post_install_message:
284
+ changelog_uri: https://github.com/yob/pdf-reader/blob/v2.7.0/CHANGELOG
285
+ documentation_uri: https://www.rubydoc.info/gems/pdf-reader/2.7.0
286
+ source_code_uri: https://github.com/yob/pdf-reader/tree/v2.7.0
287
+ post_install_message:
284
288
  rdoc_options:
285
289
  - "--title"
286
290
  - PDF::Reader Documentation
@@ -293,15 +297,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
297
  requirements:
294
298
  - - ">="
295
299
  - !ruby/object:Gem::Version
296
- version: 1.9.3
300
+ version: '2.0'
297
301
  required_rubygems_version: !ruby/object:Gem::Requirement
298
302
  requirements:
299
303
  - - ">="
300
304
  - !ruby/object:Gem::Version
301
305
  version: '0'
302
306
  requirements: []
303
- rubygems_version: 3.0.3
304
- signing_key:
307
+ rubygems_version: 3.2.3
308
+ signing_key:
305
309
  specification_version: 4
306
310
  summary: A library for accessing the content of PDF files
307
311
  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