hexapdf 0.14.2 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +96 -0
  3. data/lib/hexapdf/cli/form.rb +30 -8
  4. data/lib/hexapdf/configuration.rb +19 -4
  5. data/lib/hexapdf/content/canvas.rb +1 -0
  6. data/lib/hexapdf/dictionary.rb +3 -0
  7. data/lib/hexapdf/dictionary_fields.rb +1 -1
  8. data/lib/hexapdf/encryption/security_handler.rb +7 -2
  9. data/lib/hexapdf/encryption/standard_security_handler.rb +12 -0
  10. data/lib/hexapdf/error.rb +4 -3
  11. data/lib/hexapdf/filter.rb +1 -0
  12. data/lib/hexapdf/filter/crypt.rb +60 -0
  13. data/lib/hexapdf/font/true_type/subsetter.rb +5 -1
  14. data/lib/hexapdf/font/type1/afm_parser.rb +2 -1
  15. data/lib/hexapdf/parser.rb +46 -14
  16. data/lib/hexapdf/pdf_array.rb +3 -0
  17. data/lib/hexapdf/revision.rb +16 -0
  18. data/lib/hexapdf/serializer.rb +10 -3
  19. data/lib/hexapdf/tokenizer.rb +44 -3
  20. data/lib/hexapdf/type/acro_form.rb +1 -0
  21. data/lib/hexapdf/type/acro_form/appearance_generator.rb +32 -17
  22. data/lib/hexapdf/type/acro_form/button_field.rb +8 -4
  23. data/lib/hexapdf/type/acro_form/field.rb +1 -0
  24. data/lib/hexapdf/type/acro_form/form.rb +37 -0
  25. data/lib/hexapdf/type/acro_form/signature_field.rb +223 -0
  26. data/lib/hexapdf/type/annotation.rb +13 -9
  27. data/lib/hexapdf/type/annotations/widget.rb +3 -1
  28. data/lib/hexapdf/type/font_descriptor.rb +9 -2
  29. data/lib/hexapdf/type/page.rb +81 -0
  30. data/lib/hexapdf/type/resources.rb +4 -0
  31. data/lib/hexapdf/type/xref_stream.rb +7 -0
  32. data/lib/hexapdf/utils/graphics_helpers.rb +4 -4
  33. data/lib/hexapdf/version.rb +1 -1
  34. data/test/hexapdf/content/test_canvas.rb +21 -0
  35. data/test/hexapdf/encryption/test_security_handler.rb +15 -0
  36. data/test/hexapdf/encryption/test_standard_security_handler.rb +26 -0
  37. data/test/hexapdf/filter/test_crypt.rb +21 -0
  38. data/test/hexapdf/font/true_type/test_subsetter.rb +2 -0
  39. data/test/hexapdf/font/type1/test_afm_parser.rb +5 -0
  40. data/test/hexapdf/test_dictionary_fields.rb +7 -0
  41. data/test/hexapdf/test_parser.rb +82 -2
  42. data/test/hexapdf/test_revision.rb +21 -0
  43. data/test/hexapdf/test_serializer.rb +10 -0
  44. data/test/hexapdf/test_tokenizer.rb +50 -0
  45. data/test/hexapdf/test_writer.rb +2 -2
  46. data/test/hexapdf/type/acro_form/test_appearance_generator.rb +24 -3
  47. data/test/hexapdf/type/acro_form/test_button_field.rb +13 -7
  48. data/test/hexapdf/type/acro_form/test_field.rb +5 -0
  49. data/test/hexapdf/type/acro_form/test_form.rb +46 -2
  50. data/test/hexapdf/type/acro_form/test_signature_field.rb +38 -0
  51. data/test/hexapdf/type/annotations/test_widget.rb +2 -0
  52. data/test/hexapdf/type/test_annotation.rb +20 -10
  53. data/test/hexapdf/type/test_font_descriptor.rb +7 -0
  54. data/test/hexapdf/type/test_page.rb +187 -49
  55. data/test/hexapdf/type/test_resources.rb +6 -0
  56. data/test/hexapdf/type/test_xref_stream.rb +7 -0
  57. data/test/hexapdf/utils/test_graphics_helpers.rb +8 -0
  58. metadata +6 -2
@@ -194,6 +194,12 @@ describe HexaPDF::Type::Resources do
194
194
  assert_equal([:PDF, :Text, :ImageB, :ImageC, :ImageI], @res[:ProcSet].value)
195
195
  end
196
196
 
197
+ it "handles an invalid ProcSet containing a single value instead of an array" do
198
+ @res[:ProcSet] = :PDF
199
+ @res.validate
200
+ assert_equal([:PDF], @res[:ProcSet].value)
201
+ end
202
+
197
203
  it "removes invalid procedure set names from ProcSet" do
198
204
  @res[:ProcSet] = [:PDF, :Unknown]
199
205
  @res.validate
@@ -71,6 +71,13 @@ describe HexaPDF::Type::XRefStream do
71
71
  assert(section[10, 0].in_use?)
72
72
  assert_equal(250, section[10, 0].pos)
73
73
  end
74
+
75
+ it "fails if there is not enough data available" do
76
+ @obj[:Index] = [1, 2, 10, 4]
77
+ @obj[:W] = [1, 2, 1]
78
+ @obj.stream = "abcd"
79
+ assert_raises(HexaPDF::MalformedPDFError) { @obj.xref_section }
80
+ end
74
81
  end
75
82
 
76
83
  describe "trailer" do
@@ -15,9 +15,17 @@ describe HexaPDF::Utils::GraphicsHelpers do
15
15
  assert_equal([10, 12], calculate_dimensions(5, 6, rwidth: 10))
16
16
  end
17
17
 
18
+ it "returns the requested width and the given height if width is zero" do
19
+ assert_equal([10, 6], calculate_dimensions(0, 6, rwidth: 10))
20
+ end
21
+
18
22
  it "returns the requested height and an adjusted width" do
19
23
  assert_equal([10, 12], calculate_dimensions(5, 6, rheight: 12))
20
24
  end
25
+
26
+ it "returns the requested height and the given width if height is zero" do
27
+ assert_equal([5, 12], calculate_dimensions(5, 0, rheight: 12))
28
+ end
21
29
  end
22
30
 
23
31
  describe "point_on_line" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hexapdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-22 00:00:00.000000000 Z
11
+ date: 2021-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse
@@ -267,6 +267,7 @@ files:
267
267
  - lib/hexapdf/filter.rb
268
268
  - lib/hexapdf/filter/ascii85_decode.rb
269
269
  - lib/hexapdf/filter/ascii_hex_decode.rb
270
+ - lib/hexapdf/filter/crypt.rb
270
271
  - lib/hexapdf/filter/encryption.rb
271
272
  - lib/hexapdf/filter/flate_decode.rb
272
273
  - lib/hexapdf/filter/lzw_decode.rb
@@ -358,6 +359,7 @@ files:
358
359
  - lib/hexapdf/type/acro_form/choice_field.rb
359
360
  - lib/hexapdf/type/acro_form/field.rb
360
361
  - lib/hexapdf/type/acro_form/form.rb
362
+ - lib/hexapdf/type/acro_form/signature_field.rb
361
363
  - lib/hexapdf/type/acro_form/text_field.rb
362
364
  - lib/hexapdf/type/acro_form/variable_text_field.rb
363
365
  - lib/hexapdf/type/action.rb
@@ -507,6 +509,7 @@ files:
507
509
  - test/hexapdf/filter/common.rb
508
510
  - test/hexapdf/filter/test_ascii85_decode.rb
509
511
  - test/hexapdf/filter/test_ascii_hex_decode.rb
512
+ - test/hexapdf/filter/test_crypt.rb
510
513
  - test/hexapdf/filter/test_encryption.rb
511
514
  - test/hexapdf/filter/test_flate_decode.rb
512
515
  - test/hexapdf/filter/test_lzw_decode.rb
@@ -593,6 +596,7 @@ files:
593
596
  - test/hexapdf/type/acro_form/test_choice_field.rb
594
597
  - test/hexapdf/type/acro_form/test_field.rb
595
598
  - test/hexapdf/type/acro_form/test_form.rb
599
+ - test/hexapdf/type/acro_form/test_signature_field.rb
596
600
  - test/hexapdf/type/acro_form/test_text_field.rb
597
601
  - test/hexapdf/type/acro_form/test_variable_text_field.rb
598
602
  - test/hexapdf/type/actions/test_launch.rb