Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Repeat PDF template on every page #375

Closed
evgenyneu opened this Issue · 7 comments

7 participants

@evgenyneu

It would be nice to have a PDF template repeated on every page. For example, I have a single page PDF file with a header graphics containing company logo. It would be nice to use this page as a template for all pages. Currently, if I create a document with template: /path/to.pdf option, it only puts it on the first page.

@mopx

you can assign a template when you create a new page

start_new_page(:template => filename.pdf)

@evgenyneu

@mopx that's cool, thank you. The only problem in my case is that I do not deliberately create pages. I just output text and images and pages are added automatically. Is there a way to tell Prawn to use the PDF as a template each time a new page needs to be added?

@vizjerai

I have the same issue. I've got a table that has a lot of data and it'll automatically create a new page. But it'll call start_new_page without any options.

https://github.com/prawnpdf/prawn/blob/master/lib/prawn/document/bounding_box.rb#L456-462

def move_past_bottom
  if @document.page_number == @document.page_count
    @document.start_new_page
  else
    @document.go_to_page(@document.page_number + 1)
  end
end

document/column_box.rb has a similar problem but doesn't affect my issue.

Looks like if this is the same issue that I'm having. this is a duplicate with #273

@vizjerai

Suggestion by Aristata that I found in the google groups for a work around with a few modifications.

https://groups.google.com/d/msg/prawn-ruby/d_h7_vd7Iss/P7lAGQsMwnMJ

Define a method start_new_page(options)

def start_new_page(options={})
  opts = options.reverse_merge({
    :template => @path_to_template,
    :template_page => @template_page
  })
 super(opts)
end
@alexmonteiro

Same problem with template without using start_new_page command, when I print a list of products more than 1 page the template doesn't appear the template on other pages.

It ill be a good improve if symbol :template works like :top_magin on behavior. The :top_margin on create of pdfs is working on all pages printed.

@jonsgreen
Collaborator

I can imagine having another option for a new document name :page_template that would use that page_template whenever start_new_page is called internally. We would need to store the template reference somewhere (DocumentState?).

@yob
Collaborator
yob commented

I agree that this would definitely need to be an addition to the API - not all users want the template to apply to new pages automatically.

@practicingruby practicingruby removed the stale label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.