pdf-reader 2.4.2 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +44 -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/bounding_rectangle_runs_filter.rb +16 -0
  8. data/lib/pdf/reader/buffer.rb +63 -21
  9. data/lib/pdf/reader/cid_widths.rb +1 -0
  10. data/lib/pdf/reader/cmap.rb +5 -3
  11. data/lib/pdf/reader/encoding.rb +3 -2
  12. data/lib/pdf/reader/error.rb +11 -3
  13. data/lib/pdf/reader/filter/ascii85.rb +7 -1
  14. data/lib/pdf/reader/filter/ascii_hex.rb +6 -1
  15. data/lib/pdf/reader/filter/depredict.rb +10 -8
  16. data/lib/pdf/reader/filter/flate.rb +4 -2
  17. data/lib/pdf/reader/filter/lzw.rb +2 -0
  18. data/lib/pdf/reader/filter/null.rb +1 -0
  19. data/lib/pdf/reader/filter/run_length.rb +19 -13
  20. data/lib/pdf/reader/filter.rb +1 -0
  21. data/lib/pdf/reader/font.rb +44 -0
  22. data/lib/pdf/reader/font_descriptor.rb +1 -0
  23. data/lib/pdf/reader/form_xobject.rb +1 -0
  24. data/lib/pdf/reader/glyph_hash.rb +16 -9
  25. data/lib/pdf/reader/glyphlist-zapfdingbats.txt +245 -0
  26. data/lib/pdf/reader/lzw.rb +4 -2
  27. data/lib/pdf/reader/null_security_handler.rb +1 -0
  28. data/lib/pdf/reader/object_cache.rb +1 -0
  29. data/lib/pdf/reader/object_hash.rb +8 -3
  30. data/lib/pdf/reader/object_stream.rb +1 -0
  31. data/lib/pdf/reader/overlapping_runs_filter.rb +11 -4
  32. data/lib/pdf/reader/page.rb +73 -11
  33. data/lib/pdf/reader/page_layout.rb +37 -37
  34. data/lib/pdf/reader/page_state.rb +18 -23
  35. data/lib/pdf/reader/page_text_receiver.rb +68 -6
  36. data/lib/pdf/reader/pages_strategy.rb +1 -0
  37. data/lib/pdf/reader/parser.rb +15 -7
  38. data/lib/pdf/reader/point.rb +25 -0
  39. data/lib/pdf/reader/print_receiver.rb +1 -0
  40. data/lib/pdf/reader/rectangle.rb +113 -0
  41. data/lib/pdf/reader/reference.rb +1 -0
  42. data/lib/pdf/reader/register_receiver.rb +1 -0
  43. data/lib/pdf/reader/resource_methods.rb +5 -0
  44. data/lib/pdf/reader/standard_security_handler.rb +1 -0
  45. data/lib/pdf/reader/standard_security_handler_v5.rb +1 -0
  46. data/lib/pdf/reader/stream.rb +1 -0
  47. data/lib/pdf/reader/synchronized_cache.rb +1 -0
  48. data/lib/pdf/reader/text_run.rb +14 -6
  49. data/lib/pdf/reader/token.rb +1 -0
  50. data/lib/pdf/reader/transformation_matrix.rb +1 -0
  51. data/lib/pdf/reader/unimplemented_security_handler.rb +1 -0
  52. data/lib/pdf/reader/width_calculator/built_in.rb +8 -15
  53. data/lib/pdf/reader/width_calculator/composite.rb +1 -0
  54. data/lib/pdf/reader/width_calculator/true_type.rb +1 -0
  55. data/lib/pdf/reader/width_calculator/type_one_or_three.rb +1 -0
  56. data/lib/pdf/reader/width_calculator/type_zero.rb +1 -0
  57. data/lib/pdf/reader/width_calculator.rb +1 -0
  58. data/lib/pdf/reader/xref.rb +7 -1
  59. data/lib/pdf/reader/zero_width_runs_filter.rb +13 -0
  60. data/lib/pdf/reader.rb +29 -6
  61. data/lib/pdf-reader.rb +1 -0
  62. data/rbi/pdf-reader.rbi +1763 -0
  63. metadata +12 -7
  64. 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.2
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Healy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-28 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
@@ -239,13 +240,13 @@ files:
239
240
  - lib/pdf/reader/font_descriptor.rb
240
241
  - lib/pdf/reader/form_xobject.rb
241
242
  - lib/pdf/reader/glyph_hash.rb
243
+ - lib/pdf/reader/glyphlist-zapfdingbats.txt
242
244
  - lib/pdf/reader/glyphlist.txt
243
245
  - lib/pdf/reader/lzw.rb
244
246
  - lib/pdf/reader/null_security_handler.rb
245
247
  - lib/pdf/reader/object_cache.rb
246
248
  - lib/pdf/reader/object_hash.rb
247
249
  - lib/pdf/reader/object_stream.rb
248
- - lib/pdf/reader/orientation_detector.rb
249
250
  - lib/pdf/reader/overlapping_runs_filter.rb
250
251
  - lib/pdf/reader/page.rb
251
252
  - lib/pdf/reader/page_layout.rb
@@ -253,7 +254,9 @@ files:
253
254
  - lib/pdf/reader/page_text_receiver.rb
254
255
  - lib/pdf/reader/pages_strategy.rb
255
256
  - lib/pdf/reader/parser.rb
257
+ - lib/pdf/reader/point.rb
256
258
  - lib/pdf/reader/print_receiver.rb
259
+ - lib/pdf/reader/rectangle.rb
257
260
  - lib/pdf/reader/reference.rb
258
261
  - lib/pdf/reader/register_receiver.rb
259
262
  - lib/pdf/reader/resource_methods.rb
@@ -272,14 +275,16 @@ files:
272
275
  - lib/pdf/reader/width_calculator/type_one_or_three.rb
273
276
  - lib/pdf/reader/width_calculator/type_zero.rb
274
277
  - lib/pdf/reader/xref.rb
278
+ - lib/pdf/reader/zero_width_runs_filter.rb
279
+ - rbi/pdf-reader.rbi
275
280
  homepage: https://github.com/yob/pdf-reader
276
281
  licenses:
277
282
  - MIT
278
283
  metadata:
279
284
  bug_tracker_uri: https://github.com/yob/pdf-reader/issues
280
- changelog_uri: https://github.com/yob/pdf-reader/blob/v2.4.2/CHANGELOG
281
- documentation_uri: https://www.rubydoc.info/gems/pdf-reader/2.4.2
282
- source_code_uri: https://github.com/yob/pdf-reader/tree/v2.4.2
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
283
288
  post_install_message:
284
289
  rdoc_options:
285
290
  - "--title"
@@ -293,7 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
298
  requirements:
294
299
  - - ">="
295
300
  - !ruby/object:Gem::Version
296
- version: 1.9.3
301
+ version: '2.0'
297
302
  required_rubygems_version: !ruby/object:Gem::Requirement
298
303
  requirements:
299
304
  - - ">="
@@ -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