hexapdf 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/hexapdf/content/canvas.rb +1 -0
- data/lib/hexapdf/utils/graphics_helpers.rb +4 -4
- data/lib/hexapdf/version.rb +1 -1
- data/test/hexapdf/content/test_canvas.rb +21 -0
- data/test/hexapdf/test_writer.rb +2 -2
- data/test/hexapdf/utils/test_graphics_helpers.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 310d9fc74134cb2840118b3637c35a3037909d707532116680ef2fe6f42c43d3
|
4
|
+
data.tar.gz: 76f05b220e101114d4a4136d8c07520cfe35e1e532652ea4e43593a4b812284c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e811e637b859f3e327ece6af28174bd6602cec0585af596c9b174127ab7276752c3e519e668757933945f2906f4a6856a96e68575eb9139f32365bfa6b8a36b
|
7
|
+
data.tar.gz: 54e94c7d6704a340d1e5a5ad7b35e0715b06b6604ecec4671a079cea6049f786308258a44378280597d59e66c17e4eefd6317e94fe9a465671c2d093a7395ad3
|
data/CHANGELOG.md
CHANGED
@@ -1260,6 +1260,7 @@ module HexaPDF
|
|
1260
1260
|
unless obj.kind_of?(HexaPDF::Stream)
|
1261
1261
|
obj = context.document.images.add(obj)
|
1262
1262
|
end
|
1263
|
+
return obj if obj.width == 0 || obj.height == 0
|
1263
1264
|
|
1264
1265
|
width, height = calculate_dimensions(obj.width, obj.height,
|
1265
1266
|
rwidth: width, rheight: height)
|
@@ -47,18 +47,18 @@ module HexaPDF
|
|
47
47
|
#
|
48
48
|
# +rwidth+::
|
49
49
|
# The requested width. If +rheight+ is not specified, it is chosen so that the aspect
|
50
|
-
# ratio is maintained
|
50
|
+
# ratio is maintained. In case of +width+ begin zero, +height+ is used for the height.
|
51
51
|
#
|
52
52
|
# +rheight+::
|
53
53
|
# The requested height. If +rwidth+ is not specified, it is chosen so that the aspect
|
54
|
-
# ratio is maintained
|
54
|
+
# ratio is maintained. In case of +height+ begin zero, +width+ is used for the width.
|
55
55
|
def calculate_dimensions(width, height, rwidth: nil, rheight: nil)
|
56
56
|
if rwidth && rheight
|
57
57
|
[rwidth, rheight]
|
58
58
|
elsif rwidth
|
59
|
-
[rwidth, height * rwidth / width.to_f]
|
59
|
+
[rwidth, width == 0 ? height : height * rwidth / width.to_f]
|
60
60
|
elsif rheight
|
61
|
-
[width * rheight / height.to_f, rheight]
|
61
|
+
[height == 0 ? width : width * rheight / height.to_f, rheight]
|
62
62
|
else
|
63
63
|
[width, height]
|
64
64
|
end
|
data/lib/hexapdf/version.rb
CHANGED
@@ -831,6 +831,17 @@ describe HexaPDF::Content::Canvas do
|
|
831
831
|
[:restore_graphics_state]])
|
832
832
|
end
|
833
833
|
|
834
|
+
it "doesn't do anything if the image's width or height is zero" do
|
835
|
+
@image[:Width] = 0
|
836
|
+
@canvas.xobject(@image, at: [0, 0])
|
837
|
+
assert_operators(@page.contents, [])
|
838
|
+
|
839
|
+
@image[:Width] = 10
|
840
|
+
@image[:Height] = 0
|
841
|
+
@canvas.xobject(@image, at: [0, 0])
|
842
|
+
assert_operators(@page.contents, [])
|
843
|
+
end
|
844
|
+
|
834
845
|
it "correctly serializes the form with no options" do
|
835
846
|
@canvas.xobject(@form, at: [1, 2])
|
836
847
|
assert_operators(@page.contents, [[:save_graphics_state],
|
@@ -862,6 +873,16 @@ describe HexaPDF::Content::Canvas do
|
|
862
873
|
[:paint_xobject, [:XO1]],
|
863
874
|
[:restore_graphics_state]])
|
864
875
|
end
|
876
|
+
|
877
|
+
it "doesn't do anything if the form's width or height is zero" do
|
878
|
+
@form[:BBox] = [100, 50, 100, 200]
|
879
|
+
@canvas.xobject(@form, at: [0, 0])
|
880
|
+
assert_operators(@page.contents, [])
|
881
|
+
|
882
|
+
@form[:BBox] = [100, 50, 150, 50]
|
883
|
+
@canvas.xobject(@form, at: [0, 0])
|
884
|
+
assert_operators(@page.contents, [])
|
885
|
+
end
|
865
886
|
end
|
866
887
|
|
867
888
|
describe "character_spacing" do
|
data/test/hexapdf/test_writer.rb
CHANGED
@@ -40,7 +40,7 @@ describe HexaPDF::Writer do
|
|
40
40
|
219
|
41
41
|
%%EOF
|
42
42
|
3 0 obj
|
43
|
-
<</Producer(HexaPDF version 0.15.
|
43
|
+
<</Producer(HexaPDF version 0.15.1)>>
|
44
44
|
endobj
|
45
45
|
xref
|
46
46
|
3 1
|
@@ -72,7 +72,7 @@ describe HexaPDF::Writer do
|
|
72
72
|
141
|
73
73
|
%%EOF
|
74
74
|
6 0 obj
|
75
|
-
<</Producer(HexaPDF version 0.15.
|
75
|
+
<</Producer(HexaPDF version 0.15.1)>>
|
76
76
|
endobj
|
77
77
|
2 0 obj
|
78
78
|
<</Length 10>>stream
|
@@ -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.15.
|
4
|
+
version: 0.15.1
|
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-04-
|
11
|
+
date: 2021-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmdparse
|