hexapdf 0.11.5 → 0.11.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 245de775fa069ad91f2fe9f5e72610df40211e8b15a92b376cdf217c63b877fe
4
- data.tar.gz: 34891827479def7d0efd506c9cd62f10abced99b8e694e39bc0dd06b1fa88bfe
3
+ metadata.gz: 60a5bf5332e0ebf949653852c2f77a7a78861b120bf0c5eed30ee6591cd0736e
4
+ data.tar.gz: 79c8495ffcf48c4d81180ab9aa39e5ee12386f0a015ccef2460e453a879609d3
5
5
  SHA512:
6
- metadata.gz: 0c8bedff161a8aa756d6ffc426c89554e82537198692250a78f0eaad36fa896767681bda681d43bdcd5237f3eba91d25679499bbbe56ff525a16813c06187636
7
- data.tar.gz: 35f82390333d2110c7ccb3059c93914e7ab03bbcd986c0ca7da1d3425c5a2c619aa42513da15d218423917e01f696b7b4e156f00b1997007c9feb637ae921d20
6
+ metadata.gz: ded53b4977a8caafc8811b80f42fd0e137fed0af84072ee864a30f02ac729d5327f85840c2f7eb21426a5f3beee8caa6b2d40f91e0521180f161db8ccad86a48
7
+ data.tar.gz: c1f7c2fb6e6fd2eacef1d11421768844471d0b048bf0eb36558f6a0a6426eed3438db1309aa17e3cd4e7a1e973affab946b52073c10ad7a37e0d9c3ce46cf3b8
@@ -1,3 +1,11 @@
1
+ ## 0.11.6 - 2020-05-27
2
+
3
+ ### Fixed
4
+
5
+ * [HexaPDF::Layout::TextBox] to respect the set width and height when fitting
6
+ and splitting the box
7
+
8
+
1
9
  ## 0.11.5 - 2020-01-27
2
10
 
3
11
  ### Changed
@@ -107,6 +107,8 @@ module HexaPDF
107
107
  # Deletes the given page object from the document's page tree (but *not* from the document).
108
108
  #
109
109
  # Returns the page object, or +nil+ if the page object was not in the page tree.
110
+ #
111
+ # Also see: HexaPDF::Type::PageTreeNode#delete_page
110
112
  def delete(page)
111
113
  @document.catalog.pages.delete_page(page)
112
114
  end
@@ -118,6 +120,8 @@ module HexaPDF
118
120
  # document).
119
121
  #
120
122
  # Returns the page object, or +nil+ if the index was invalid.
123
+ #
124
+ # Also see: HexaPDF::Type::PageTreeNode#delete_page
121
125
  def delete_at(index)
122
126
  @document.catalog.pages.delete_page(index)
123
127
  end
@@ -64,6 +64,9 @@ module HexaPDF
64
64
  #
65
65
  # Also see TextLayouter#style for other style properties taken into account.
66
66
  def fit(available_width, available_height, frame)
67
+ return false if (@initial_width > 0 && @initial_width > available_width) ||
68
+ (@initial_height > 0 && @initial_height > available_height)
69
+
67
70
  @width = @height = 0
68
71
  @result = if style.position == :flow
69
72
  @tl.fit(@items, frame.width_specification, frame.contour_line.bbox.height)
@@ -74,8 +77,8 @@ module HexaPDF
74
77
  height = (@initial_height > 0 ? @initial_height : available_height) - @height
75
78
  @tl.fit(@items, width, height)
76
79
  end
77
- @width += @result.lines.max_by(&:width)&.width || 0
78
- @height += @result.height
80
+ @width += (@initial_width > 0 ? width : @result.lines.max_by(&:width)&.width || 0)
81
+ @height += (@initial_height > 0 ? height : @result.height)
79
82
  if style.last_line_gap && @result.lines.last
80
83
  @height += style.line_spacing.gap(@result.lines.last, @result.lines.last)
81
84
  end
@@ -86,7 +89,9 @@ module HexaPDF
86
89
  # Splits the text box into two boxes if necessary and possible.
87
90
  def split(available_width, available_height, frame)
88
91
  fit(available_width, available_height, frame) unless @result
89
- if @result.remaining_items.empty?
92
+ if @width > available_width || @height > available_height
93
+ [nil, self]
94
+ elsif @result.remaining_items.empty?
90
95
  [self]
91
96
  elsif @result.lines.empty?
92
97
  [nil, self]
@@ -37,6 +37,6 @@
37
37
  module HexaPDF
38
38
 
39
39
  # The version of HexaPDF.
40
- VERSION = '0.11.5'
40
+ VERSION = '0.11.6'
41
41
 
42
42
  end
@@ -31,11 +31,11 @@ describe HexaPDF::Layout::TextBox do
31
31
  end
32
32
 
33
33
  it "respects the set width and height" do
34
- box = create_box([@inline_box] * 5, width: 40, height: 50, style: {padding: 10})
34
+ box = create_box([@inline_box], width: 40, height: 50, style: {padding: 10})
35
35
  assert(box.fit(100, 100, @frame))
36
36
  assert_equal(40, box.width)
37
37
  assert_equal(50, box.height)
38
- assert_equal([20, 20, 10], box.instance_variable_get(:@result).lines.map(&:width))
38
+ assert_equal([10], box.instance_variable_get(:@result).lines.map(&:width))
39
39
  end
40
40
 
41
41
  it "fits into the frame's outline" do
@@ -52,6 +52,16 @@ describe HexaPDF::Layout::TextBox do
52
52
  assert_equal(50, box.width)
53
53
  assert_equal(20, box.height)
54
54
  end
55
+
56
+ it "can't fit the text box if the set width is bigger than the available width" do
57
+ box = create_box([@inline_box], width: 101)
58
+ refute(box.fit(100, 100, @frame))
59
+ end
60
+
61
+ it "can't fit the text box if the set height is bigger than the available height" do
62
+ box = create_box([@inline_box], height: 101)
63
+ refute(box.fit(100, 100, @frame))
64
+ end
55
65
  end
56
66
 
57
67
  describe "split" do
@@ -70,6 +80,14 @@ describe HexaPDF::Layout::TextBox do
70
80
  assert_equal([nil, box], box.split(5, 20, @frame))
71
81
  end
72
82
 
83
+ it "works if the whole text box doesn't fits" do
84
+ box = create_box([@inline_box], width: 102)
85
+ assert_equal([nil, box], box.split(100, 100, @frame))
86
+
87
+ box = create_box([@inline_box], height: 102)
88
+ assert_equal([nil, box], box.split(100, 100, @frame))
89
+ end
90
+
73
91
  it "splits the box if necessary" do
74
92
  box = create_box([@inline_box] * 10)
75
93
  boxes = box.split(50, 10, @frame)
@@ -40,7 +40,7 @@ describe HexaPDF::Writer do
40
40
  219
41
41
  %%EOF
42
42
  3 0 obj
43
- <</Producer(HexaPDF version 0.11.5)>>
43
+ <</Producer(HexaPDF version 0.11.6)>>
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.11.5)>>
75
+ <</Producer(HexaPDF version 0.11.6)>>
76
76
  endobj
77
77
  2 0 obj
78
78
  <</Length 10>>stream
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.11.5
4
+ version: 0.11.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-27 00:00:00.000000000 Z
11
+ date: 2020-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse
@@ -102,11 +102,9 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - CHANGELOG.md
105
- - CONTRIBUTERS
106
105
  - LICENSE
107
106
  - README.md
108
107
  - Rakefile
109
- - VERSION
110
108
  - agpl-3.0.txt
111
109
  - bin/hexapdf
112
110
  - data/hexapdf/afm/Courier-Bold.afm
@@ -401,7 +399,6 @@ files:
401
399
  - lib/hexapdf/version.rb
402
400
  - lib/hexapdf/writer.rb
403
401
  - lib/hexapdf/xref_section.rb
404
- - man/man1/hexapdf.1
405
402
  - test/data/aes-test-vectors/CBCGFSbox-128-decrypt.data.gz
406
403
  - test/data/aes-test-vectors/CBCGFSbox-128-encrypt.data.gz
407
404
  - test/data/aes-test-vectors/CBCGFSbox-192-decrypt.data.gz
@@ -637,7 +634,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
637
634
  - !ruby/object:Gem::Version
638
635
  version: '0'
639
636
  requirements: []
640
- rubygems_version: 3.1.2
637
+ rubygems_version: 3.0.3
641
638
  signing_key:
642
639
  specification_version: 4
643
640
  summary: HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
@@ -1,5 +0,0 @@
1
- Count Name
2
- ======= ====
3
- 1104 Thomas Leitner <t_leitner@gmx.at>
4
- 1 Stanislav (Stas) Katkov <sk@skylup.com>
5
- 1 Daniel Kraus <bovender@bovender.de>
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.11.5
File without changes