I have a PDF attachment. I want to add the contents of this attachment to another VF page that is rendered as PDF. Is there any way to parse the PDF contents in salesforce, which allows us to parse the content of the PDF and add them to another page?

| improve this question | | | | |

I doubt there is such feature in salesforce. But many online services as aspose might help you here although most of them are cost money.

| improve this answer | | | | |

The answer to your question would be "it depends". As background, in the late 1990's I was in the Desktop Publishing business and was a volunteer sysop in the Adobe Forum on CompuServe. I also beta tested their software. So I have some intimate knowledge of the subject and what one can do with these files.

I say "it depends" because it would greatly depend on your knowledge of the postscript printer language. "PDF" is an acronym for "Portable Document File" (now correct thanks to nudge from sfdcfox). PDF's are derivatives of output files originally intended for processing by postscript printers. There are many 3rd party PDF editors, readers and software printer drivers (RIPs and emulators) available. There's even a WORD plug-in for creating PDF forms. What all that means is that if you're familiar with the language, you can do most anything you want.

If you want to "roll your own code", I suggest you visit the Adobe web site to review the postscript docs, API, etc. You'll probably also want to look at Adobe AIR for Salesforce as that might come in handy as well even though it's primarily used for adding Flash animations to VisualForce pages. I say that because I believe it provides access to other Adobe developer functions as well, but can't say that for certain as I've not spent any time playing with it.

Otherwise, if the first attachment is rendered from another VisualForce page, your best bet would be to create a custom controller that combines the functionality of the two different VisualForce pages and print them both at once. The latter would require far less development time than rolling your own PDF processor; something that's not a trivial task.

| improve this answer | | | | |
  • 3
    Not trying to nitpick, but the file format is actually the "Portable Document Format" (e.g. see Wikipedia), and while it is true that it was derived from a "PS" (PostScript) file, a PDF file is significantly more complex, including possible compression and font tables. It is highly unlikely that any PDF of any size would be directly accessible in salesforce.com, due to the amount of CPU time given, plus the fact that one cannot "directly" manipulate bits in Apex Code (there is no "byte" type, for example). – sfdcfox Jul 9 '13 at 16:22
  • Oops! You're right about the name being Portable Document Format. Was too early in the morning when I wrote this. That said, if one is basically trying to join the two files into one, I don't see that as being nearly as difficult as creating a general PDF RIP. No doubt that one would have to assume no encryption or overall file compression of the PDF. But then, my experience goes back to Acrobat 3 and there have been many new features implemented since then.(grin) I know of booklet layout software for printers that was fairly simple & I could see this being similar. – crmprogdev Jul 9 '13 at 20:01

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.