1

I am facing a bizarre issue. I am creating a PDF dynamically using images stored in the system. I am using a VF page and using RenderAs="pdf" to generate the file. Everything is working as expected. However, there is one specific image that comes inverted in the pdf. When I remove the renderAs and just render as a VF page the image is shown correctly. I have also checked the file by downloading it and it's proper.

Additionally, I have deleted the file and reuploaded it, and it still comes out inverted.

It's quite trivial since it's one specific image at the moment, but I would like to avoid this issue for future uploads. Can anyone give me a clue as to why it is being rendered upside down?

Thanks!

1
  • 2
    Hi. Could you please edit your question to add VF page markup snippets for the image handling, a screenshot of the original image and a screenshot of what you are seeing in the PDF rendering?
    – Phil W
    Sep 24 '20 at 9:33
2

JPEG images have an "orientation" tag that can be set by the camera or image editor. For example, an image can be stored upside down in the file, but the tag states the image is stored upside down, and the browser will flip it right side up so it looks right.

However, not all image rendering systems understand this tag, including presumably the pdf renderer in Salesforce (the Flying Saucer HTML to PDF library), and thus the image comes out the wrong side up. See this article for more details on how the tag is used.

Even though it may appear right side up on your computer, it could be in one of eight possible orientations. You'll need to use ImageMagick, jpegexiforient, or another tool to actually reorder the pixels in the file to be right side up according to the orientation tag, then reupload the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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