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
ptran123ptran123 

CSS style not being applied for renderAs="pdf"

Baffling, I don't think I am doing anything wrong since I've created PDFs like this before.  Based on the code below, the div should pick up the style.  Not the case.

 

<apex:page renderAs="pdf">
<html>
  <head>
    <style>
      #message {
        color: red;
      }
    </style>
</head>

  <div id="message">Should display in red</div>
</html>
</apex:page>

 

I have other PDF pages that render out correctly.  I copied that code over to this new VF page.  Same issue as stated.  I've tried with recreated a new VF page. No success.  I am stumped.  Any help is appreciated.

ptran123ptran123
OK. Looks like a version issue. I changed the Apex version to 26.0 on the page and looks like it displays correctly now. It had been set to version 27.0 (new in Spring ’13 release). Not sure what’s up with that.
Prafull G.Prafull G.

Seems like you figured out and resolved the issue by fixing version number. However, if you want to use the latest version i.e. 27.0 then You do not need to specify <html> tags explictly on your page.

 

Try removing the <html> tag from your code and check. It should work.

 

Cheers!

Shiv ShankarShiv Shankar

Try this one.

<apex:page renderAs="pdf" standardStyleSheet = "false">