XDP File using remote PDF - pdf

In one of our applications, we have a script dump data from a database into a well-formed XDP file, which the user can download. The XDP contains a reference to a PDF on the same server via the <pdf> tag. The idea is the user can dump the data, get the XDP, which will download the PDF and automatically fill in the data, which they can then save, print, or e-mail.
The problem is that Adobe Reader (or Acrobat) instead opens the default web browser to try to download the PDF, and if you open it from the browser it does not automatically populate the data dumped from the database. If I take the XDP and use a text editor to change the link in the <pdf> tag to a locally downloaded copy, the form populates fine, so the XDP is written correctly, however this is not a practical solution, as most users wouldn't know how to do that.
My question is if there is a way to automate this process, so that Adobe Reader or Acrobat downloads the PDF file and populates the data automatically, and doesn't try to route the process through the web browser.
EDIT
Using Seeker's answer we came up with the following short snippet in PHP:
$filename = ""; // Your file here
$contents = base64_encode(file_get_contents($filename));
Then in the PHP file that handles the XML:
<pdf xmlns="http://ns.adobe.com/xdp/pdf/">
<document>
<chunk><?php echo $contents ?></chunk>
</document>
</pdf>

I was dealing with the exact same issue today. You should include the PDF file using Base64 encoding inside your xdp file.
in your XDP file replace this: <pdf href="http://.../form.pdf"> with :
<pdf xmlns="http://ns.adobe.com/xdp/pdf/"><document>
<chunk>**CONTENT OF YOUR PDF IN BASE64 GOES HERE**</chunk>
</document>
</pdf>
That should solve your problem.

Related

cfdocument not converting Word Document to PDF correctly

cfdocument in ColdFusion 11 is not converting my Word Documents to PDF correctly. I have OpenOffice 4.1.3 installed and configured in CF Admin. I am able to open the source document in OpenOffice and Export to PDF without issue. However, when I run the following code, the resulting PDF is "gobbledigook":
<cfdocument
format="pdf"
srcfile="#_tempSourceFilePath#"
filename="#_destinationFilePath#" />
Here is an excerpt of the resulting PDF (the snip shows developer edition, but, the same thing happens with Standard installation):
I can't figure out why this is happening. Any ideas?
The problem is:
srcfile="#_tempSourceFilePath#"
This is apparently the path to a binary file that is not browser-writable. A necessary condition for the srcfile attribute is that the file be browser-writable. That is, without the need for a browser plugin.

Save Livecycle PDF file before submitting to server

I have created a LiveCycle PDF form that includes a Submit button to send it as XDP (including the base64 encoded PDF) to a server that pulls out the XML data and saves that to a database and then pulls out the encoded stream, decodes it and saves that back as a PDF on the server.
The issue that I am having is that once I open the PDFs made from the base64 encoded data, it seems that they are empty. After some testing I found that if I manually save the PDF before Submitting it, the information that was entered up to when it was saved is included in the encoded PDF (whereas the full data is included in the XML portion).
So my question is there a way to either:
Automatically save the PDF or otherwise preserve the data so it is sent in the base64 encoded portion of the XDP? (preferable)
Recognize when a change in the document has changed and request that the user save the PDF before clicking submit?
It seems the issue I described above was actually due to using Foxit reader instead of Adobe reader.
Adobe reader of course requires the Reader Extensions in order to be able to save form data and submit it.
Foxit does not have that restriction but does not embed the updated version of the PDF in the XDP XML data sent to the server. The only way to perform this would be ensure the user saves the PDF first which removes the Reader Extensions as per Adobe's licensing requirements.

Sending PDF file back to client

I have made a wizard with a button. On buttons action the function generates a PDF file on the server. How can I send back this file from server disk to the client ?
If it's not a report, write the PDF file in a binary field.
See the export language wizard for example

Submitting a PDF file and saving in ColdFusion

I need users to be able to fill out a form in a PDF file using their browser then, when they click the submit button in the PDF file's form, a new PDF file is saved with the contents they entered in the form.
One of the main examples I have been referencing is Adobe's help section on this subject, but have had no luck: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec11c2b-7ffa.html
The PDF file I was provided didn't have a submit action associated with it. So, I opened up LiveCycle designer and found the submit button and added this code to it:
<submit format="pdf" target="http://localhost:8500/pdfforms/pdfreceiver.cfm" textEncoding="UTF-16" xdpContent="pdf datasets xfdf"/>
Changing the target to the correct location on my local server, of course. Then, when I use this portion of code:
<cfpdfform source="#PDF.content#" action="read" result="fields"/>
<cfdump var="#fields#">
I get an error saying:
Element CONTENT is undefined in PDF.
I also tried opening it up in Adobe Acrobat X Pro and setting the action to submit the entire PDF file, but that didn't work either. I'm using ColdFusion 9 on Windows 7 if that helps any. Thanks in advance for your help!
You don't use CFPDFFORM to read the results from submitting a PDF. The PDF form should do a FORM POST to the target page, just like an html web form.
You can see the results of the form by doing a CFDUMP on the FORM scope:
<cfdump var="#form#">
Then you use a variety of methods to parse through and store that information in a database.

Best practice to display the PDF file in the browser?

Am currently working on a web application which receives the encoded text from the web service and am decoding & saving as a PDF file. Once the user clicks for the details then I am supposed to display the PDF file in the web browser.
What is the best practice to display the PDF file in the browser? Am using VB.Net 2003
All you need to do is set the link to point to your pdf file. And if the user has any PDF reader installed, it will be opened using that reader.
The name you Want to Show as Link
EDIT:
The other way, if you dont want to display as link and directly open the file, is to set the correct MIME type in the headers, so that the browsers can detect it as PDF file instead of HTML file.
Response.AddHeader("content-disposition","inline;filename=YourPdfFileName.pdf")
Response.End