Hi Group,I'm just working on a PDF-Generator. I want to use a fancy PDF as a template. The template has 2 pages. I'm trying to achieve to get the first page of the template on the first page of the new generated pdf and the second page of the template on all following pages of the new generated pdf. First step is no Problem. I'm generating a pdf with this:Prawn::Document.generate(filename, :page_size => "A4", :skip_page_creation => true) do |pdf|# Afterwards i set the template for the first site like this:pdf.start_new_page(:template => path_to_template, template_page => 1)Now i'm generating content. And this content is getting longer and longer... At some point a new page is automatically generated, but without any template. Because of not running the method #start_new_page on the second page, i have no template. Just a Guess!The Question is: But how is it possible to define :template for following pages, which are not especially generated by the method #start_new_page? Did i miss something? I'm happy about every bit of information.Cheers, Georg
Define a method start_new_page(options)def start_new_page(options={})opts = options.reverse_merge!({:template => path_to_template})super(opts)
end
Correct, you are overriding the method which *is* called automatically when a new page begins, passing it your options, then letting super take care of the rest!
Hey Christopher,
Thank you for your comment and your inside view. Helped me a lot to understand prawn and the dynamic aspect of ruby.
Cheers, Georg