2

I want to edit a PDF file in the Salesforce Document folder to add some text or background image to it, and then save the changes in a new PDF document.

I tried to include the PDF in a Visualforce page using and render this page as PDF. But that didn't work, because renderAs="PDF" didn't display the iframe in the output PDF. Clearly, PDF generation in Visualforce only works with some components.

Do you have any idea how to achieve PDF manipulation in Apex/Visualforce? I thought of using a Heroku service for which I can send the PDF file to do the PDF manipulation (In Java, Ruby on any other language). Is that a viable option? Do you know any ready-to-use Heroku services that can do the job?

Thanks in advance for your help. Riadh.

2
  • I suggest you check the App Exchange. There are a number of 3rd party PDF solutions. I don't recall who's does what, but if you're looking at a Heroku Solution, it may be substantially less expensive to pay for the cost of a license to a vendor. Editing a PDF would be somewhat like editing a Postscript Print file. A Java App would be a more plausible solution.
    – crmprogdev
    Commented Nov 10, 2014 at 15:24
  • Hi, just wondering where you able to do this? I am having a similar issue, conga will work perfect but it doesnt merge images, it seems that I will have to create a doc file and then converted to pdf
    – manza
    Commented Sep 23, 2015 at 23:15

2 Answers 2

5

PDF is a binary format and Apex (presumably by design) is missing the language capabilities to manipulate bits and bytes. So it is not possible to edit the internals of a PDF file in Apex.

The purpose of the renderAs="PDF" is to run code that generates a PDF file from the HTML tags and CSS in a Visualforce page. It has nothing to do with rendering a pre-existing PDF file.

So yes, if you an find an existing library that does what you need, you could host it on e.g. Heroku. You would be extremely lucky to find such a setup that already exists; you are more likely to need to create that service yourself.

2

You can edit PDFs directly in a desktop browser using PDFNetJS, a pure JavaScript PDF editing (and viewing library) from PDFTron. The post at https://groups.google.com/d/msg/pdfnet-webviewer/0gcL_ncdCrQ/BrHkHLZdBQAJ has more information.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .