Copy link to clipboard
Copied
I have a problem when trying to add footers to the bottom of a PDF. It would seem that there might be a BUG in ADOBE's DDX processing;
When I try to add a footer on this particular document I get the following when I cfdump out the ddx variable:
failed: CCITTFaxDecode Filter
So this document has a fax image in it (not a real shocker) but why do we get these sort of problems?
Does anyone have a solution?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It sounds like a bug. As a work-around, you can use iText instead of ddx to add footers. Here is an example that adds page x of y footers.
<cfscript>
pathToInputFile = ExpandPath("GDC.pdf");
pathToOutputFile = ExpandPath("GDC_Stamped.pdf");
try {
// create the footer font
BaseFont = createObject("java", "com.lowagie.text.pdf.BaseFont");
footerFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
// read in the input file
reader = createObject("java", "com.lowagie.text.pdf.PdfReader").init(pathToInputFile);
totalPages = reader.getNumberOfPages();
// create a stamper for modifying the pdf
outStream = createObject("java", "java.io.FileOutputStream").init( pathToOutputFile );
stamper = createObject("java", "com.lowagie.text.pdf.PdfStamper").init(reader, outStream);
// for each page
i = 0;
while (i LT totalPages) {
i = i + 1;
// add page numbers to the overcontent layer
over = stamper.getOverContent( javacast("int", i) );
over.beginText();
over.setFontAndSize(footerFont, javacast("float", 18) );
over.setTextMatrix( javacast("float", 30), javacast("float", 30) );
over.showText("Page " & i &" of "& totalPages);
over.endText();
}
WriteOutput("Finished!");
}
catch (java.lang.Exception e) {
savedErrorMessage = e;
WriteOutput("Unable to create document "& e.message);
}
// closing PdfStamper will generate the new PDF file
if (IsDefined("stamper")) {
stamper.close();
}
if (IsDefined("outStream")) {
outStream.close();
}
</cfscript>