Skip to content
This repository

Repeat PDF template on every page #375

evgenyneu opened this Issue July 23, 2012 · 7 comments

7 participants

Evgenii Neumerzhitckii Gregory Brown Jorge Yau Andrew Assarattanakul Alexander Monteiro Jonathan James Healy
Evgenii Neumerzhitckii

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.

Jorge Yau
mopx commented July 27, 2012

you can assign a template when you create a new page

start_new_page(:template => filename.pdf)

Evgenii Neumerzhitckii

@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?

Andrew Assarattanakul

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.

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

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

Andrew Assarattanakul

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

Define a method start_new_page(options)

def start_new_page(options={})
  opts = options.reverse_merge({
    :template => @path_to_template,
    :template_page => @template_page
Alexander Monteiro

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.


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

James Healy

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.

Gregory Brown sandal closed this November 19, 2013
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.