prawn-table 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/prawn/table.rb +9 -3
- data/lib/prawn/table/cells.rb +3 -0
- data/prawn-table.gemspec +2 -17
- data/spec/table_spec.rb +25 -0
- metadata +5 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad3cd4b7b737957cfc9d5ab8a0673a27606a245b
|
4
|
+
data.tar.gz: c2b1d37a6c8e25ebd2de9ef3d322032e8d5667df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bddf85d78a3bd370b49939fe5808778bb0160c3dfb9360b67d7a49441592ff9501deb1f382eadfe3d4c30bf502fceeb773774302dc380f33dce909e2960447fe
|
7
|
+
data.tar.gz: 63131251d4c12ece20b5be3af29e3ad4724d9276dbafad4b9ca71cc506ff8c61f0cba53daadda2e65b92a050e39e7621ef4782ad38e8076d56fd0b40dc63afb4
|
data/lib/prawn/table.rb
CHANGED
@@ -473,7 +473,8 @@ module Prawn
|
|
473
473
|
needed_height = row(0..number_of_header_rows).height
|
474
474
|
|
475
475
|
# have we got enough room to fit the first row (including header row(s))
|
476
|
-
|
476
|
+
use_reference_bounds = true
|
477
|
+
return -1 if fits_on_page?(needed_height, use_reference_bounds)
|
477
478
|
|
478
479
|
# If there isn't enough room left on the page to fit the first data row
|
479
480
|
# (including the header), start the table on the next page.
|
@@ -484,8 +485,13 @@ module Prawn
|
|
484
485
|
end
|
485
486
|
|
486
487
|
# do we have enough room to fit a given height on to the current page?
|
487
|
-
def fits_on_page?(needed_height)
|
488
|
-
|
488
|
+
def fits_on_page?(needed_height, use_reference_bounds = false)
|
489
|
+
if use_reference_bounds
|
490
|
+
bounds = @pdf.reference_bounds
|
491
|
+
else
|
492
|
+
bounds = @pdf.bounds
|
493
|
+
end
|
494
|
+
needed_height < @pdf.y - (bounds.absolute_bottom - Prawn::FLOAT_PRECISION)
|
489
495
|
end
|
490
496
|
|
491
497
|
# return the header rows
|
data/lib/prawn/table/cells.rb
CHANGED
data/prawn-table.gemspec
CHANGED
@@ -26,23 +26,8 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency('prawn-manual_builder', ">= 0.2.0")
|
27
27
|
spec.add_development_dependency('pdf-reader', '~>1.2')
|
28
28
|
|
29
|
-
spec.homepage = "
|
29
|
+
spec.homepage = "https://github.com/prawnpdf/prawn-table"
|
30
30
|
spec.description = <<END_DESC
|
31
|
-
Prawn
|
32
|
-
END_DESC
|
33
|
-
spec.post_install_message = <<END_DESC
|
34
|
-
|
35
|
-
********************************************
|
36
|
-
|
37
|
-
|
38
|
-
A lot has changed recently in Prawn.
|
39
|
-
|
40
|
-
Please read the changelog for details:
|
41
|
-
|
42
|
-
https://github.com/prawnpdf/prawn/wiki/CHANGELOG
|
43
|
-
|
44
|
-
|
45
|
-
********************************************
|
46
|
-
|
31
|
+
Prawn::Table provides tables for the Prawn PDF toolkit
|
47
32
|
END_DESC
|
48
33
|
end
|
data/spec/table_spec.rb
CHANGED
@@ -1576,4 +1576,29 @@ describe "colspan / rowspan" do
|
|
1576
1576
|
t.cells[2, 2].content.should == "h"
|
1577
1577
|
t.cells[2, 3].content.should == "i"
|
1578
1578
|
end
|
1579
|
+
|
1580
|
+
it 'illustrates issue #20', issue: 20 do
|
1581
|
+
pdf = Prawn::Document.new
|
1582
|
+
description = "one\ntwo\nthree"
|
1583
|
+
bullets = description.split("\n")
|
1584
|
+
bullets.each_with_index do |bullet, ndx|
|
1585
|
+
rows = [[]]
|
1586
|
+
|
1587
|
+
if ndx < 1
|
1588
|
+
rows << [ { content: "blah blah blah", colspan: 2, font_style: :bold, size: 12, padding_bottom: 1 }]
|
1589
|
+
else
|
1590
|
+
rows << [ { content: bullet, width: 440, padding_top: 0, align: :justify } ]
|
1591
|
+
end
|
1592
|
+
pdf.table(rows, header: true, cell_style: { border_width: 0, inline_format: true })
|
1593
|
+
end
|
1594
|
+
pdf.render
|
1595
|
+
end
|
1596
|
+
|
1597
|
+
it 'illustrates issue #20 (2) and #22', issue: 22 do
|
1598
|
+
pdf = Prawn::Document.new
|
1599
|
+
pdf.table [['one', 'two']], position: :center
|
1600
|
+
pdf.table [['three', 'four']], position: :center
|
1601
|
+
pdf.render
|
1602
|
+
pdf.page_count.should == 1
|
1603
|
+
end
|
1579
1604
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prawn-table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory Brown
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2014-
|
16
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: prawn
|
@@ -142,7 +142,7 @@ dependencies:
|
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '1.2'
|
144
144
|
description: |2
|
145
|
-
Prawn
|
145
|
+
Prawn::Table provides tables for the Prawn PDF toolkit
|
146
146
|
email:
|
147
147
|
- gregory.t.brown@gmail.com
|
148
148
|
- brad@bradediger.com
|
@@ -195,26 +195,13 @@ files:
|
|
195
195
|
- spec/spec_helper.rb
|
196
196
|
- spec/table/span_dummy_spec.rb
|
197
197
|
- spec/table_spec.rb
|
198
|
-
homepage:
|
198
|
+
homepage: https://github.com/prawnpdf/prawn-table
|
199
199
|
licenses:
|
200
200
|
- RUBY
|
201
201
|
- GPL-2
|
202
202
|
- GPL-3
|
203
203
|
metadata: {}
|
204
|
-
post_install_message:
|
205
|
-
|
206
|
-
********************************************
|
207
|
-
|
208
|
-
|
209
|
-
A lot has changed recently in Prawn.
|
210
|
-
|
211
|
-
Please read the changelog for details:
|
212
|
-
|
213
|
-
https://github.com/prawnpdf/prawn/wiki/CHANGELOG
|
214
|
-
|
215
|
-
|
216
|
-
********************************************
|
217
|
-
|
204
|
+
post_install_message:
|
218
205
|
rdoc_options: []
|
219
206
|
require_paths:
|
220
207
|
- lib
|