FDF multiple form syntax

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
repp9418
Forum Newbie
Posts: 10
Joined: Thu Jan 17, 2008 10:37 am

FDF multiple form syntax

Post 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;
}
repp9418
Forum Newbie
Posts: 10
Joined: Thu Jan 17, 2008 10:37 am

Re: FDF multiple form syntax

Post by repp9418 »

Does anyone know the FDF template syntax?
repp9418
Forum Newbie
Posts: 10
Joined: Thu Jan 17, 2008 10:37 am

RESOLVED: FDF multiple form syntax

Post 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.
Post Reply