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
StrangeRoutinesStrangeRoutines 

RenderAs pdf with font variant, small caps, possible bug or not supported?

I have a customer requirement to display a PDF document with various parts of it in "small caps". If I display the document as a regular VF page, its fine. However, when I add the renderAs="PDF" attribute, the small caps disappear. The document is complex with many styling changes and requires a separate style sheet. However, the problem is easy to demonstrate with a simple document, e.g.:

 

<apex:page sidebar="false" standardStyleSheets="false" showHeader="false">
<style type="text/css">
p {font-variant:small-caps;}
</style>
<p>This should be small caps.</p>
</apex:page>

 

The above works as expected.  However, add in the renderAs, and the small caps disappear!

 

I have tried everything. I've tried setting the body selector, I've tried spanning with a class or an id. I've used a separate style sheet, wrapped the text in an apex:outputText tag and then added style and/or styleclass attributes to the apex tag. I've tried specifying font families (which is a real shot in the dark since I've found no documentation on what fonts are available to SFDC's iText instances.)

 

Has anybody seen this before or have a solution or know if this a confirmed bug? [My OS is WinXP SP3 5.1.2600 (i.e. fully up to date) and my Adobe Reader is 8.2.5 (i.e. fully up to date)]

 

I can think of a workaround but for large docs, its ugly. You would change the required words to uppercase and use two fonts, one for trailing parts of words and a larger one for the leading character, where needed.

SSRS2SSRS2

Try with your style tag within the head tag.To PDF output style tag need to be in <head></head> tag.

 

<apex:page sidebar="false" standardStyleSheets="false" showHeader="false" renderAs="pdf">
 <head>
  <style type="text/css">
   p {font-variant:small-caps;}
  </style>
 </head>
 <p>This should be small caps.</p>
</apex:page>

 -Suresh

 

 

StrangeRoutinesStrangeRoutines

Sadly, that doesn't work either. Nice try though. And, if it did work other comments/problems arise:

 

1) Why are they necessary just for PDF rendering? Nowhere in the VF Developers Guide does it show using the <head></head> tags with the notable exception of  the "Rendering a page asPDF" section where it also includes the <html></html> tags, but not <body></body> tags. I have tried various combinations of all of those with no success.

 

2) It it did work, then why would not the <html> and <body> tags also be necessary?  (Baring discusssions about what exact DTD VF is, of course!)

 

3) Keep  in mind the above VF code is a cut down sample. In the REAL code, I am using a separate stylesheet so adding a <head></head> tag to the VF page would be unlikely to help anyway.

SSRS2SSRS2

Hi try with this

<apex:page sidebar="false" standardStyleSheets="false" showHeader="false" renderAs="pdf">
 <head>
  <style type="text/css">
   body {font-variant:small-caps;}
  </style>
 </head>
 <p>This should be small caps.</p>
</apex:page>

In salesforce their sample is incorrect see following 

Can't apply css styles when renderAs="PDF"

-Suresh

StrangeRoutinesStrangeRoutines

I should also note that, in this test case only, rendering in PDF also ignores your font selection.  If you skip the renderAs and specify a font-family of, say, cursive, you get  small-caps cursive, just as you would expect. But when you throw in the renderAs, you get Times Roman.  You can see it in the PDF file if you save it and open it with a plain old editor.

 

Really makes you wonder what they are feeding to the iText routines!  Again, its also pity that there is no documentation as to what font files are available to the iText renderer.

StrangeRoutinesStrangeRoutines

Nope, still doesn't work. And again, this is only a simple example. In the real document, I have to have small-caps all over the place and from a style sheet. This really looks like a bug to me. Even if it did work, all of these extra tags shouldn't be necessary just to render in PDF. Frankly, I am also finding other things that DON'T render the same in PDF as in non-PDF including a particularly horrific violation of the CSS box-model (or could have be a break down in selector logic, it's hard to tell.)