problem with table - cell - colspan / rowspan

1,831 views
Skip to first unread message

alexei

unread,
May 25, 2012, 12:54:54 AM5/25/12
to Prawn
I am using Prawn with Ruby on Rails 3.2.3.

Prawn was installed as gem (gem 'prawn') via bundle.

Attempts to render an example included in "table/span.rb" failed with
error message:
undefined method `colspan=' for...

Here is the captured text of example:
table([
["A", {:content => "2x1", :colspan => 2}, "B"],
[{:content => "1x2", :rowspan => 2}, "C", "D", "E"],
[{:content => "2x2", :colspan => 2, :rowspan => 2}, "F"],
["G", "H"]
])

When colspan / rowspan were removed and extra fields added to fill up
the space (as show below) the rendering works fine.

table([
["A", {:content => "2x1"}, "B", "B2"],
[{:content => "1x2"}, "C", "D", "E"],
[{:content => "2x2"}, "F", "f2", "f3" ],
["G", "H", "h2", "h3"]
])

What do I need to get colspan / rowspan work?

Thanks
Alexei

Brad Ediger

unread,
May 25, 2012, 8:43:03 AM5/25/12
to prawn...@googlegroups.com
On Thu, May 24, 2012 at 11:54 PM, alexei <alexei.b...@gmail.com> wrote:
> I am using Prawn with Ruby on Rails 3.2.3.
>
> Prawn was installed as gem (gem 'prawn')  via bundle.
>
> Attempts to render an example included in "table/span.rb" failed with
> error message:
> undefined method `colspan=' for...

Colspan support is not in the latest stable gem release. It is in
1.0.0.rc1, which you can include with:

gem 'prawn', '1.0.0.rc1'

-be

alexey bochkarev

unread,
May 25, 2012, 1:23:08 PM5/25/12
to prawn...@googlegroups.com
Updated gem to
gem 'prawn', '1.0.0.rc1'
Still getting same error message:
undefined method `colspan=' for ...
Thanks
Alexei

Brad Ediger

unread,
May 25, 2012, 1:25:44 PM5/25/12
to prawn...@googlegroups.com
On Fri, May 25, 2012 at 12:23 PM, alexey bochkarev
<alexei.b...@gmail.com> wrote:
> Updated gem to
> gem 'prawn', '1.0.0.rc1'
> Still getting same error message:
> undefined method `colspan=' for ...

My mistake, colspan was in fact introduced after the RC1. You can run
from our master branch like this:

gem 'prawn', git: 'git://github.com/prawnpdf/prawn', branch: 'master'

-be

alexey bochkarev

unread,
May 25, 2012, 9:32:23 PM5/25/12
to prawn...@googlegroups.com
Brad, thanks!

One step forward and a new related problem.
Simple form of colspan works with the git version..
However, rendering aborts if colspan used in combination with other
table options.
Here are the details:

colspan_data = [
["A", {:content => "2x1", :colspan => 2}, "B"],
[{:content => "1x2", :rowspan => 2}, "C", "D", "E"],
[{:content => "2x2", :colspan => 2, :rowspan => 2}, "F"],
["G", "H"]
]
no_span_data = [
["A", {:content => "2x1"}, "B", "b2"],
[{:content => "1x2"}, "C", "D", "E"],
[{:content => "2x2"}, "F", "f2", "f3"],
["G", "H", "h2","h3"]
]

pdf.table no_span_data
pdf.table colspan_data

Both work fine.

pdf.table no_span_data, :width => 510
pdf.table colspan_data, :width => 510

Both work fine.

pdf.table no_span_data, :column_widths => [130, 90, 160, 130]
works fine

pdf.table colspan_data, :column_widths => [130, 90, 160, 130]
Aborts with error message:
Table's width was set too small to contain its contents (min width
545.0, requested 540.0)

Thanks
Alexei

mrpink

unread,
Apr 16, 2013, 3:09:48 PM4/16/13
to prawn...@googlegroups.com
Any news on this issue? Got exact the same problem!
Message has been deleted

Peter

unread,
Jun 17, 2013, 7:57:16 PM6/17/13
to prawn...@googlegroups.com
+1

I am having this problem also.  Getting the error:

Table's width was set too small to contain its contents

I am using Prawn 1.0.0.rc2.  I am trying to use colspan to center some table headers over 2 and 3 columns of data (which have widths passed in as standardized variables).  I suppose I could make a new table containing just the headers and place it on top of the data columns, but that seems a little hack-y to me. What to do?
Reply all
Reply to author
Forward
0 new messages