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
ChichoChicho 

Render a Visualforce page as PDF issues

I'm trying to render a HTML table in a Visualvorce page as PDF and I'm having the following issues:

 

  1. I used the CSS below to display the page in landscape but it doesn't work.
<style >
    @page { 
        size:landscape;
   }
 </style>

 

 

2. When rendering the VF page as PDF, the table is displayed without the colors I added using CSS.

 

3.How can I create a button that shows the VF page ready to be printed out?

 

Thank you very much!

Best Answer chosen by Admin (Salesforce Developers) 
Satish_SFDCSatish_SFDC

Hi,

Please sorround your style tag with a head tag.

 

<head>
  <style>
    @page {
      size:landscape;
    }
  </style> 
</head>

 

Also i observed that the render as pdf was not working in the version 27 or version 28. I had to change the visualforce version to version 26.

 

Hope this helps.

 

Regards,

Satish Kumar


Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.

 

All Answers

Satish_SFDCSatish_SFDC

Hi,

Please sorround your style tag with a head tag.

 

<head>
  <style>
    @page {
      size:landscape;
    }
  </style> 
</head>

 

Also i observed that the render as pdf was not working in the version 27 or version 28. I had to change the visualforce version to version 26.

 

Hope this helps.

 

Regards,

Satish Kumar


Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.

 

This was selected as the best answer
ChichoChicho

Thanks! Still doesn't work as I think it is because I'm using the version 28. Is there a way to solve this without downgrading the version?

Satish_SFDCSatish_SFDC

Hi,

I am not sure of any other ways. But let me check the known issues site to see if this is already reported.

 

Regards,

Satish Kumar