This may not be possible, but I am wondering if there is a way to generate multiple PDF pages within a PDF based on the copies an contact requests when filling out an online form. It's like this.

1) A user in a form specifies that they are purchasing X tickets for an event, if the user wants just 1 ticket, then the attached PDF from the visualforce autoreply will generate a PDF with just one page only. If the user wants 2 tickets, then 2 pages and so on and so forth, with the page number specified somewhere in the template.

Let me know if this is achievable.


Yes, this is entirely possible and can be fairly easily done. Implementation would depend largely on the page design for the "ticket", but mostly involves using the "ticket count" as an <apex: repeat> on the visualforce page and also in the footer or header for the page count which is sent to the page from the controller.

As a very simplified example, if you had a page that consisted of a table with your ticket inside it, you'd set it up something like this:

<apex: page  controller='mycustomcontroller' renderas='pdf'>
<apex: repeat>

//.... page content for ticket 

<table footer> 
// content with pagecount variable
</table footer>
</apex: repeat>
</apex: page>

In your CSS for the page, you'd also include CSS for the Table that has style="page-break-after: always;"

Another way of adding the page number to the page itself, instead of to the footer of the table, is to do something like this in your CSS instead:

@page {
   size: 8.5in 11in;
   margin: 10%;
   @top-right {
   content: "Page " counter(page);

These things need to be passed to your page from the controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.