Setting page margins in the context of Prawn::Views

493 views
Skip to first unread message

Giuseppe Bertini

unread,
Jan 28, 2015, 12:06:19 PM1/28/15
to prawn...@googlegroups.com
The manual states:

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
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.

-greg

On 1/28/15 12:06 PM, Giuseppe Bertini wrote:
> The manual <http://prawnpdf.org/manual.pdf> states:
> --
> You received this message because you are subscribed to the Google
> Groups "Prawn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to prawn-ruby+...@googlegroups.com
> <mailto:prawn-ruby+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Giuseppe Bertini

unread,
Feb 3, 2015, 5:19:18 AM2/3/15
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 .

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.

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
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
> <https://github.com/giuseb/prawn/blob/view-help/manual/basic_concepts/view.rb>.
Reply all
Reply to author
Forward
0 new messages