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.

  • 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 Nov 10 '14 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 Sep 23 '15 at 23:15
4

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.

| improve this answer | |
1

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.

| improve this answer | |

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.