Search code examples
pdfacrobatlivecycleadobe-reader

XDP File using remote 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>

Solution

  • 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.