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:
<style>
.headerLogo{
max-height:100px;
max-width:200px;
}
</style>
<div class="header">
<div>
<img class="headerLogo" src="{!imageURL}"/>
</div>
</div>
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?
Best Answer
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):
In repositories such as https://github.com/flyingsaucerproject/flyingsaucer there isn't obvious evidence that the
max-height
andmax-width
are supported for images. So trywidth
orheight
instead in your CSS.