6

Let's start with an existing PDF that has fillable form fields.

The end goal is to populate those fields with SFDC data and display the PDF in the browser.

What I've tried so far:

I've created an XFDF file that will populate the PDF. I can generate that file using apex. However, I'm not sure how to get from an XFDF file to a PDF file in the browser. It sounds like 3rd party tools or libraries are generally used to do that and I don't see an easy solution in SFDC.

Right now I'm thinking I'm going to have to recreate the existing PDF in VisualForce. I was hoping to avoid that but it doesn't sound like there is an easier solution out there.

2
  • If it's not a requirement that the PDF you generate still has editable form fields, VF native PDF to recreate the original sounds like your best bet. Otherwise you'll need a browser- or desktop-based solution to crunch together a PDF and XFDF. That may be OK if you have control over your users' desktops, but probably not ideal.
    – jkraybill
    Mar 26, 2013 at 0:49
  • Hi Ryan,The closes you can get is congo composer which can generate pdf to other document formats Mar 26, 2013 at 4:50

3 Answers 3

2

It isn't necessary to go through a VF page in order to create a PDF. Instead, you can write your own custom PDF controller that's called from a button on an existing page (one that has queryable links to all the data objects you need) and then have the completed PDF output in a new window. If you're looking to automatically save it as a file, there are some autosave methods you might be able to use in conjunction with what I'm describing, but I've never attempted or had the need to do something along those lines with a PDF Controller.

Since you say you're able to create XFDF files using APEX, I'd expect that writing the VisualForce controller shouldn't be that difficult for you. The way I've done these in the past is to create an HTML template with custom CSS. Then it became a case of populating fields and using repeats wherever tabular data existed. There are also some "tricks" here and there in the CSS that can help with pagination if that's something you need to accomplish. Also, some people lay out the complete document in the controller, then send it to the page while others simply send it to the page. There's a tutorial in the SF documentation on writing a PDF controller using the former method. Unfortunately, I don't recall at the moment which workbook it's in.

1
0

We are currently doing this in our Salesforce instance. If you VIEW the XFDF file, the browser should attempt to open it with Adobe Reader. From there Reader will know which PDF to pull (b/c it is referenced in the XFDF file) and merge the data that is present.

Only roadblock that we have found for this is on iPad(iOS/Safari). In this environment, Safari does not know what to do with the XFDF file (missing file association possibly) and displays message saying it can't download the file.

0

Have a look at the link here. In the tutorial they merge a record from their salesforce instance into a predetermined PDF form when a button is clicked and display it.

https://developer.salesforce.com/page/Adobe_XFDF

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.