Merge FDF and PDF without PDFTK
Asked Answered
C

1

6

Is there a way to merge FDF file and a PDF File to create a flat format of all the data and form into 1 pdf without using PDFTK?

Any light shed upon this would be greatly appreciated.

Carotenoid answered 11/1, 2011 at 1:31 Comment(2)
Does this have to be a command line app, or is there some particular programming language you can use?Sinasinai
It would be great to have it done in PHP...Carotenoid
K
0

No.. There's no other way easy way to flatten, but it's awesome. Why would you need anything else?

PDFTK is actually mostly Java (literally hundreds of Java files). You could think about wrapping your own project around it. The functionality that you're looking for is here (java/com/lowagie/text/pdf/AcroFields.java:931):

/** Sets the fields by XFDF merging.
 * @param xfdf the XFDF form
 * @throws IOException on error
 * @throws DocumentException on error
 */
public boolean setFields(XfdfReader xfdf) throws IOException, DocumentException {
    boolean ret_val_b= false; // ssteward
    xfdf.getFields();
    for (Iterator i = fields.keySet().iterator(); i.hasNext();) {
        String f = (String)i.next();
        String v = xfdf.getFieldValue(f);
        String rv = xfdf.getFieldRichValue(f); // ssteward
        if (rv != null)
            ret_val_b= true;
        if (v != null)
            setField(f, v, v, rv); // ssteward
    }
    return ret_val_b; // ssteward
}
Kovrov answered 8/9, 2011 at 22:55 Comment(1)
pdftk is written in iText, as you mentioned with java/com/lowagie/text/pdf/AcroFields.java. Thus you mean using iText instead of wrapping it around pdftk.Maniac

© 2022 - 2024 — McMap. All rights reserved.