Page 1 of 1

FDF multiple form syntax

Posted: Tue Sep 29, 2009 7:48 pm
by repp9418
I have a PDF form that I am using as a template. For every record in a database, I would like to populate the form on a new page in the same PDF file. I would also like to do this without a toolkit.

Does anyone know the FDF syntax to use one template on multiple pages in one file?

The following code works populating one form in one file.

Code: Select all

function createFDF($file,$info)
{
    $fdf = "%FDF-1.2\x0d%\xe2\xe3\xcf\xd3\x0d\x0a"; // header
    $fdf.= "1 0 obj\x0d<< "; // open the Root dictionary
    $fdf.= "\x0d/FDF << "; // open the FDF dictionary
    $fdf.= "/Fields [ "; // open the form Fields array
    foreach ($info as $field => $val) {
        if (is_array($val)) {
            $fdf.='<< /T('.addslashes($field).')/V[';
                foreach($val as $opt)
                    $fdf.='('.addslashes(trim($opt)).')';
                $fdf.='] /SetFf 1 >>';
        } else {
                $fdf.='<< /T('.addslashes($field).')/V('.addslashes(trim($val)).') /SetFf 1 >>';
        }
    }
    $fdf.= "] \x0d"; // close the Fields array
    $fdf.= "/F ($file) \x0d";
    $fdf.= ">> \x0d"; // close the FDF dictionary
    $fdf.= ">> \x0dendobj\x0d"; // close the Root dictionary
    // trailer; note the "1 0 R" reference to "1 0 obj" above
    $fdf.= "trailer\x0d<<\x0d/Root 1 0 R \x0d\x0d>>\x0d";
    $fdf.= "%%EOF\x0d\x0a";
    return $fdf;
}

Re: FDF multiple form syntax

Posted: Thu Oct 01, 2009 5:17 pm
by repp9418
Does anyone know the FDF template syntax?

RESOLVED: FDF multiple form syntax

Posted: Wed Oct 07, 2009 2:46 pm
by repp9418
It turns out that Adobe Reader does not understand/handle multiple templates in one file. So what I was trying to do cannot be read in Adobe Reader.