Skip to content

Instantly share code, notes, and snippets.

@jlduran
Last active January 3, 2016 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlduran/8457978 to your computer and use it in GitHub Desktop.
Save jlduran/8457978 to your computer and use it in GitHub Desktop.
colspan-bug sub-tables #632

The failing test code illustrates the issue.

The figure illustrates the desired PDF output (obtained by means of the workaround). It ts a sample lab test report.

The first row in the test's table is equivalent to the row containing the section heading in bold on the left (Immunology/Serology), and to the right a few details about the test (execution time, etc.). Those details to the right span 3 columns.

The second row in the test's table is equivalent to the one containig the actual test result (i.e. FSH), notice the last column (Reference Range) is actually a 4-column sub-table, to allow for proper alignment of the ranges.

The results cannot be placed in separate tables, as there are usually many test results per section that outgrow to other pages, thus the first row is used as a header/repeater.

Failure/Error: @pdf.table(data) do
Prawn::Errors::CannotFit:
Table's width was set too small to contain its contents (min width 546.0, requested 540.0)
# ./lib/prawn/table.rb:398:in `column_widths'
# ./lib/prawn/table.rb:571:in `set_column_widths'
# ./lib/prawn/table.rb:138:in `initialize'
# ./lib/prawn/table.rb:28:in `new'
# ./lib/prawn/table.rb:28:in `table'
# ./spec/table_spec.rb:77:in `block (3 levels) in <top (required)>'
describe "test case for issue 533" do
it "does no render the table" do
@pdf = Prawn::Document.new
colspan = @pdf.make_cell :content => '', :colspan => 3
data = [['', '', '', '', colspan]]
sub_table = @pdf.make_table([[nil]]) do
column(0).width = 70
column(1).width = 38
column(2).width = 6
column(3).width = 78
end
data << ['', '', '', '', sub_table]
@pdf.table(data) do
column(0).width = 140
column(1).width = 80
column(2).width = 88
column(3).width = 40
column(4).width = 192
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment