"Global" styles/tags in prawn/format

11 views
Skip to first unread message

Valera

unread,
Nov 30, 2009, 9:56:33 AM11/30/09
to Prawn
Is it possible to have certain tags/styles be available in *all*
documents?!?
By this, I mean something like:
Prawn::Document.tags[:big] = {:font_size => 20}
or
Prawn::Document.styles :big => {:font_size => 20}
or (not prawn/format, but same train-of-thought)
Prawn::Document.font_families.update('RandFont' => {:bold =>
'[wherever]', ...})

I'm interested in this because I'm using prawnto to generate some
reports, and it would be nice to put things like the above into an
initializer, so I don't have to repeat that code in every .pdf.prawn
file.

If this is not possible, I will just make a helper that does this.

Gregory Brown

unread,
Nov 30, 2009, 11:55:45 AM11/30/09
to prawn...@googlegroups.com
On Mon, Nov 30, 2009 at 9:56 AM, Valera <vetr...@gmail.com> wrote:
> Is it possible to have certain tags/styles be available in *all*
> documents?!?
> By this, I mean something like:
> Prawn::Document.tags[:big] = {:font_size => 20}

prawn-format is no longer supported starting in Prawn 0.7.

-greg

Henrik Nyh

unread,
Dec 1, 2009, 2:05:54 AM12/1/09
to prawn...@googlegroups.com
On Mon, Nov 30, 2009 at 15:56, Valera <vetr...@gmail.com> wrote:
> Is it possible to have certain tags/styles be available in *all*
> documents?!?
> By this, I mean something like:
> Prawn::Document.tags[:big] = {:font_size => 20}
> or
> Prawn::Document.styles :big => {:font_size => 20}
> or (not prawn/format, but same train-of-thought)
> Prawn::Document.font_families.update('RandFont' => {:bold =>
> '[wherever]', ...})
>
> I'm interested in this because I'm using prawnto to generate some
> reports, and it would be nice to put things like the above into an
> initializer, so I don't have to repeat that code in every .pdf.prawn
> file.

If you inherit your Prawn documents from some subclass to
Prawn::Document that you define, you could use e.g. pdf.tags in the
initializer of that class and all your documents would get it.

So

class ApplicationPrawnDocument < Prawn::Document
def initialize
super
tags :h1 => ...
end
end

class MyPrawnReport < ApplicationPrawnDocument
...
end

See here for more info on pdf.tags etc:
http://74.125.77.132/search?hl=en&q=cache%3Ahttp%3A%2F%2Fjamis.github.com%2Fprawn-format%2F&btnG=Search
Cached copy since the original isn't available, presumably because
prawn-format is not supported in Prawn 0.7 as Gregory said.

Gregory Brown

unread,
Dec 1, 2009, 10:35:49 AM12/1/09
to prawn...@googlegroups.com
On Tue, Dec 1, 2009 at 2:05 AM, Henrik Nyh <hen...@nyh.se> wrote:

> See here for more info on pdf.tags etc:
> http://74.125.77.132/search?hl=en&q=cache%3Ahttp%3A%2F%2Fjamis.github.com%2Fprawn-format%2F&btnG=Search
> Cached copy since the original isn't available, presumably because
> prawn-format is not supported in Prawn 0.7 as Gregory said.

Not so, looks like jamis deleted his repository. I'll get the
documentation back online somewhere.
Reply all
Reply to author
Forward
0 new messages