function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kent ManningKent Manning 

How to control page size when rendering a Visualforce Page as PDF

I'm creating a service report from a visual force page and rendering it as a PDF.  My problem is the report is for our Germany office and their standard paper size is A4,  not 8.5" x 11".  How do I control the page size when rendering my visualforce page as a PDF?

 

Where does the generated PDF get its parameters to know wheather to format to 8.5" x 11" or some other page size?  Does this information come from the browser, the printer, or is it hard coded by Salesforce in the rendering engine? 

 

Any help ASAP would be appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
Pradeep_NavatarPradeep_Navatar

You can use page property to get the size of pdf changed in potrait or auto mode.

 

This is sample code to get style property for page :

 

<apex:page controller="Pdfgeneration"  renderAs="pdf" sidebar="false" standardStylesheets="false" showHeader="false">

 

           <head>

           <style>

           @page:first

           {

                 size:landscape;

           }

          @bottom-right

          {

                  content: "Page: " counter(page) " / " counter(pages);font-size: 80%; 

          }

          </style>

          <apex:outputText value="{!Content}"></apex:outputText>

          </head>

          </apex:page>  

 

To know more visit the link: http://www.pageresource.com/dhtml/cssprops.htm#classification_properties

All Answers

Pradeep_NavatarPradeep_Navatar

You can use page property to get the size of pdf changed in potrait or auto mode.

 

This is sample code to get style property for page :

 

<apex:page controller="Pdfgeneration"  renderAs="pdf" sidebar="false" standardStylesheets="false" showHeader="false">

 

           <head>

           <style>

           @page:first

           {

                 size:landscape;

           }

          @bottom-right

          {

                  content: "Page: " counter(page) " / " counter(pages);font-size: 80%; 

          }

          </style>

          <apex:outputText value="{!Content}"></apex:outputText>

          </head>

          </apex:page>  

 

To know more visit the link: http://www.pageresource.com/dhtml/cssprops.htm#classification_properties

This was selected as the best answer
Kent ManningKent Manning

Thanks Pradeep!

 

This works beautifully.  Thanks for sharing your expertise on this and helping me out.

 

Kent Manning