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
ryanhcaryanhca 

Making Pretty VisualForce PDFs

VisualForce pages rendered as PDF never retain the font styling and other formating present in the HTML. What have you done to make the output more like the HTML output?
Best Answer chosen by Admin (Salesforce Developers) 
TehNrdTehNrd

This thread has a post on the supported fonts. There are not many. http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=8601&query.id=474456#M8601

 

I've also found that importing a external style sheet works a lot better than inline styles for PDF generation.

All Answers

MakMak
I used html elements instead of VF tags.
ryanhcaryanhca

My VF page is 100% HTML right now, with no VF tags... I wanted to make sure I could create a nice looking PDF with static HTML first.

 

It doesn't seem to recognize CSS style sheets. If I include inline styles, it seems to recognize some. For instance, if I put:

 

<p style="font-family:Verdana;font-size:10px">Text here</p>

 

 ... it will recognize the smaller font size, but not the font face -- it'll render it in Times New Roman.

 

Table styles are completely ignored. 

 

TehNrdTehNrd

This thread has a post on the supported fonts. There are not many. http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=8601&query.id=474456#M8601

 

I've also found that importing a external style sheet works a lot better than inline styles for PDF generation.

This was selected as the best answer