Prawnto initializer block question

17 views
Skip to first unread message

mspangler

unread,
Mar 28, 2011, 9:20:21 AM3/28/11
to Prawn
I'm creating a simple PDF in Rails 3 using Prawn/Prawnto. I'm not
sure if my issue is related to Prawnto or if it's just the way i'm
doing it. The following code is in my view.

This will successfully output a table:

pdf.table([%w[foo boo], %w[bar baz]])

But I have requirements that I need to inspect certain cells of data
and if they match some criteria I must then turn the text red. Now I
know the following snippet doesn't describe the requirements but it's
an example where I've found out that nothing is evaluated in the
initializer block.

Doesn't work

pdf.table([%w[foo boo], %w[bar baz]]) do |t|
t.column(0).width = 200
end

The above snippet will output my table just like before but the first
column isn't 200 width. It seems no matter what I put after the `do`
it doesn't get evaluated. I've put complete junk and it will still
just output my table with no errors or warnings. I've seen examples
where this is possible using straight Prawn without the Prawnto plugin
but didn't know if this was a limitation of Prawnto or if I'm doing
something wrong.

Any ideas what I'm doing wrong?

Brad Ediger

unread,
Mar 28, 2011, 10:20:56 AM3/28/11
to prawn...@googlegroups.com, mspangler
On Mon, Mar 28, 2011 at 8:20 AM, mspangler <mspa...@gmail.com> wrote:
>    pdf.table([%w[foo boo], %w[bar baz]]) do |t|
>      t.column(0).width = 200
>    end
>
> The above snippet will output my table just like before but the first
> column isn't 200 width.

That syntax is only for the new (0.10+) as-yet-unreleased versions of
Prawn. We're prepping a proper 0.11.1 stable release hopefully this
week, but until then, you'll have to be building Prawn from git or
using a prerelease gem for this to work.

Brad

Reply all
Reply to author
Forward
0 new messages