27
Oct

ColdFusion, DDX, and PDFs Part 1: Gotchas

Before getting into the details of styling PDF document components using DDX, I wanted to share two very big “gotchas” that Brian and I experienced:

  1. When declaring the DDX element, make sure you copy it exactly, including the (seemingly) incorrect space in the schemaLocation.
  2. When testing your DDX using the IsDDX() function, make sure that your server isn’t locking the file

Here’s the correct DDX element to use whenever you’re trying to create a valid DDX document instance:

<DDX xmlns="http://ns.adobe.com/DDX/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ns.adobe.com/DDX/1.0/ coldfusion_ddx.xsd">

If you remove the space, IsDDX() will return false, and you’ll pull your hair out trying to create a minimal DDX that will work.

As for 2, we again discovered the file locking propensity of Windows 7 and Adobe’s Acrobat reader. Even if your PDF is downloaded from a web server, it’s quite possible to remain locked if it’s open. Whether testing with your dev server (especially a local machine) or a production server, make sure that when doing the tweak code/rerun PDF generation/view result cycle that you absolutely positively are not viewing, previewing, or have any possibility of keeping an open handle on the output PDF. If you do, once again IsDDX() will return false. Again you’ll want to pull out your hair in frustration as code that worked just a moment ago now refuses to regenerate a PDF.