Salesforce when rendering as PDF CSS styling is ignored

randy672 used Ask the Experts™
when rendering as PDF CSS styling is ignored in Salesforce

When I render a PDF page it seems to ignore any CSS styling.  Does anyone have a work around for this?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
How are you trying to render the page as PDF? I.e. are you trying to click "File>Print>Save to PDF" in your web browser?

The consistency between HTML+CSS to PDF (styled by the same CSS) is lacking. There simply isn't great standards support for CSS in PDF as there is in the web/HTML.
Are you using <apex:stylesheet> to include your CSS?
The styling is inconsistent when exporting to PDF.  You have to bring all of the CSS inline.  
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

For your visualforce page, you will have to use apex, not css or html to get it to display correctly. You can simply add the css and html into the visualforce apex formulator, but it won't display as you want without writing it in apex using the correct classes


I've requested that this question be deleted for the following reason:

solution was not provided
We use <apex:stylesheet value="{!$Resource.PrintPdf}"/> with any VF that has renderas="PDF" on.  That helps to maintain standard look and feel across pages.

<style type="text/css">
in VF directly also works for us, if there's a need for special styling.

Is there a specific element that didn't work for you?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial