Page Break, Page number and Page layout Styles in Visualforce PDF Templates

1. Page Break
While generating PDF template from Visualforce, if you want to give the page break ,below code snippet is very useful.
You can use the page break style properties to control where the browser will insert a page break. The Force.com PDF content converter will carry that over to the PDF.

<apex:page renderas="pdf">
<div style="page-break-after:always;">
This is page one
</div>
</apex:page>

2. Page layout and Page number
The following snippet shows you have to switch the PDF page layout to landscape and add page numbers to your Visualforce page. Use the below code in CSS of Visualforce page.

@page {
/* Landscape orientation */
size:landscape;

/* Put page numbers in the top right corner of each page in the pdf document. */
@top-right
{
content: “Page ” counter(page);
}
}

Source : Kyle Roche / Pragya Kumari

Share and Enjoy:
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • LinkedIn
  • Live
  • RSS
Categories: Salesforce
Pragya
Its really very helpful code and can be easily used.
5 July 10 at 15:43