+ Start a Discussion

PDF rendering and standard style sheets



Can anybody tell me why since API version 18 standardstylesheets="true" just behaves as if set to 'false' when the VF page is rendered as PDF ?  Worked well before. Is there any special action to take on VF pages when updating to version 18 and on ?


I need to update to the latest version to use rich text fields. PDF generation is critical but now with version 18, 19 or 20 it renders as if no style were defined at all even with standardstylesheets="true".




From the VF dev guide

Best Practices for Rendering PDFs

As a general rule, you shouldn't use components that:

  • Rely on JavaScript to perform an action
  • Depend on Salesforce.com stylesheets

In a nutshell, the CSS used for a browser was not designed or intended for PDF rendering.




I agree with you stephan. This is why I don't use any of the components listed as unsafe for PDF rendering in the VF guide. I also don't rely on a specific SF stylesheet (no direct reference I mean). But I did not undertand that even standardstylesheets=true cannot be done...


Then how do you get the SF look output?  Do you really need to rewrite your CSS just to look like SF output?


I solved it by including the stylesheet tag manually.


<link class="user" href="/sCSS/25.0/sprites/1344358478000/Theme3/default/gc/zen-componentsCompatible.css" rel="stylesheet" type="text/css"/>
<link class="user" href="/sCSS/25.0/sprites/1344358478000/Theme3/default/gc/elements.css" rel="stylesheet" type="text/css"/>
<link class="user" href="/sCSS/25.0/sprites/1344358478000/Theme3/default/gc/common.css" rel="stylesheet" type="text/css"/>
<link class="user" href="/sCSS/25.0/sprites/1343420890000/Theme3/gc/dStandard.css" rel="stylesheet" type="text/css"/>
<link class="user" href="/sCSS/25.0/sprites/1345062068000/Theme3/{!$Organization.ID}/{!$User.Id}/gc/dCustom0.css" rel="stylesheet" type="text/css"/>
<link class="user" href="/sCSS/25.0/sprites/1344358478000/Theme3/default/gc/extended.css" rel="stylesheet" type="text/css"/>
<link class="user" href="/sCSS/25.0/sprites/1344358478000/Theme3/default/gc/setup.css" rel="stylesheet" type="text/css"/>