Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In our org, users are able to create PDFs with a logo in the header. We're using renderAs="pdf" to achieve this. The problem is we can't control the dimensions of the logos, so we need to scale them appropriately when we render the page. Here's what I've tried:


  <div class="header">
            <img class="headerLogo" src="{!imageURL}"/>

When I don't render the page as a PDF this works great, but once i render as a PDF, the logo just expands to its original size. Is max-height/max-width supported in the Salesforce PDF generator?

share|improve this question
Are these images a known ratio or could they be pretty much anything? – Bob Roberts Aug 25 '14 at 21:12
Unfortunately they can be pretty much anything. – Sean Aug 25 '14 at 21:14
up vote 4 down vote accepted

From the "What about embedded images? Are images downscaled?" section of The Flying Saucer User's Guide (the technology usually assumed to generate PDF in Salesforce):

For intrinsic width/height calculations we assume a resolution of 96 DPI, but setting an explicit width/height makes it possible to use an arbitrary DPI.

In repositories such as there isn't obvious evidence that the max-height and max-width are supported for images. So try width or height instead in your CSS.

share|improve this answer
Unfortunately I won't know the dimensions of the logos since Users can choose their own logos, so if I set width/height it may distort the images. I want to use max-width/max-height so that that I can make sure the picture is not distorted and so it fits in the header. – Sean Aug 25 '14 at 22:20
@Sean Just set the width or the height; the other dimension should scale in proportion. But not a perfect solution. And tell your users what sizes are required/recommended/allowed. – Keith C Aug 25 '14 at 22:34
Yeah I figured that would be the best I could get. Setting just the width causes issues with tall skinny images, and just the height causes issues with short fat images. Thanks for your input! – Sean Aug 25 '14 at 22:40
@Sean There is mention in this thread word-wrap not working with VisualForce PDF generation? of the PDF engine changing in the future so eventually this problem might be solved. – Keith C Aug 26 '14 at 7:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.