For now, you can try this option in your constructor:
:on_page_stop => lambda { |pdf| pdf.text page_count, :at => [x,y }
But be advised it's disappearing in 0.2, and that 0.2 may be released today :)
-greg
--
Technical Blaag at: http://blog.majesticseacreature.com | Non-tech
stuff at: http://metametta.blogspot.com
I don't know. Because Prawn is alpha software, users will need to
make use of Github to be sure to get the latest developments.
I'll get a gem out soon, but really, I'm hoping people will try out
the stable branch any time new code has been merged, so that they can
help me test.
Otherwise, it's best to wait to use Prawn after 1.0, which will be
ready "When it's ready"
No. The next gem will be 0.2, and it will be out soon, but I'm saying
that keep in mind gem snapshots at the moment are a service to
simplify testing the library in its alpha stages, so there is no
release schedule.
> I have tried what you suggest but
>
> Prawn::Document.generate("docs.pdf", :page_size => "A4", :page_layout
> => :landscape, :on_page_stop => lambda { |pdf| pdf.text
> page_count, :at => [80,20], :size => 12 })
>
> produces
>
> undefined local variable or method `page_count' for #<Class:
> 0x33a5f2c><
>
> am I trying in the right way ?
Hi. No, you're not. Read the documentation.
>> am I trying in the right way ?
>
> Hi. No, you're not. Read the documentation.
Sorry. I see there was a typo in my code. (Though please do consult
the API docs[0])
you need pdf.page_count
This method isn't in the global namespace.
You can test them now, is the point:
http://github.com/sandal/prawn/tree/stable
That is the codebase that will become 0.2, I'm just doing cleanup
before release.
>> Hi. No, you're not. Read the documentation.
>
> the example looks quite similar to my code to me, the only difference
> I can notice is I'm using generate instead new but I guess generate
> calls new to create it before rendering it. because of that I don't
> understand where I'm wrong.
You need to use pdf.page_count, not page_count. There was a typo in my code.
> Could you please let me know where I can find more information about
> that in the documentation.
Prawn::Document#page_count.
Great
> I don't know if you just forgot but without casting page_count it is
> not possible to use it as a text.
Yup, you're right. When used in a table, cells are autoconverted with
to_s, but this is not the case with text().
General Ruby comment:
Keep in mind when you call to_s, it's not a type cast, it's just
calling the method to_s, which presumably (but in no way is forced) to
return a String. :)
-greg