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.