To create a custom class that extends Prawn's functionality, use the Prawn::View mixin. This
approach is safer than creating subclasses of Prawn::Document while being just as convenient.
If I understand correctly, when you include Prawn::View in your class, a Prawn::Document is implicitly created as soon as you invoke a Prawn::Document method.
Thus, you never actually write Prawn::Document.new(...) in your code.
But then, how is one supposed to set, say, page margins, other than by overriding the Prawn::View#document method?
Thanks,
Giuseppe
Gregory Brown
unread,
Jan 28, 2015, 12:10:03 PM1/28/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to prawn...@googlegroups.com
Both overriding the document() method in your view, or assigning your
own document to @document in a constructor are officially supported ways
to use your own document object.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to prawn...@googlegroups.com
Hi Greg, thanks for your response.
I believe that: 1) the Prawn::View approach is extremely useful; 2) in the vast majority of cases, you will want to override #document in order to set page properties to .
Please let me know if it makes sense, or if you have further suggestions, and/or if I should issue a pull request.
Cheers,
Giuseppe
Gregory Brown
unread,
Feb 3, 2015, 7:33:49 AM2/3/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to prawn...@googlegroups.com
Thanks! Please submit a pull request.
On 2/3/15 5:19 AM, Giuseppe Bertini wrote:
> Hi Greg, thanks for your response.
>
> I believe that: 1) the Prawn::View approach is extremely useful; 2) in
> the vast majority of cases, you will want to override #document in order
> to set page properties to .
>
> Thus, it seems to me that the mechanism should be explicitly shown in
> the manual, and here's how I would explain it to someone like me