it's doing. If you can reduce this to an example that you can post...
Here's a puzzling example. I've formatted the table options so that you
can turn features on and off with a comment character.
When I run the program without specifying widths, it runs
successfully and prints the width array [236, 30, 50, 199]. But if I use the
box-selection tool in the Mac OSX app "Skim" to actually measure what
is drawn on the PDF, I get [168, 59, 59, 200] (plus or minus a point or
two, depending on my mousing accuracy).
Now if I re-run the program with the puts()-alleged widths as an input
spec, it fails with this error:
Table's width was set too small to contain its contents (min width 692.5, requested 540.0) (Prawn::Errors::CannotFit)
The sum of my measurements is 486, (which includes default 5pt padding)
The sum of my specification is 515 + 40pt (padding) = 545 (not so far from 540, so I
probably misunderstood something...)
I don't understand how the min width can be 692 when it prints out just fine in
a measured width of <500 when I comment out my width specification array?
require 'rubygems'
require 'prawn'
Prawn.debug = true
Prawn::Document.generate('table_span.pdf') do
text "Randy's colspan test with specific column widths"
cnum = 'cm1112______________________'
rows = [['Randy Parker, Herb Schwartz', 'dp#', '880400', cnum]]
rows << [{:content => '1605 Chantilly Dr, Atlanta, GA, 30324', :colspan => 4}]
rows << ['Kellee Wheate, Holli Pippin ', 'dp#', '890500', cnum]
rows << [{:content => '38 Prince Charles Dr, Harwich, MA, 02645', :colspan => 4}]
table(rows,
#:cell_style => {:borders => []},
:column_widths => [236, 30, 50, 199]
) do
puts 4.times.inject([]){|array, i| array << column(i).width.to_i}.inspect
end
end
# The output printed by the puts() statement: [236, 30, 50, 199]
# But the widths measured from Mac Skim are: [168, 59, 59, 200]
# My measurement of col-3 is likely off by one, but what about cols 0 and 1 ??