#native_company# #native_desc#
#native_cta#

Create FDF file and display data in a populated PDF file

By Hank
on December 14, 2001

Version: .99

Type: Full Script

Category: Other

License: Other

Description: This program extracts names/addresses from an Informix database, creates an FDF output file which links to a PDF file, and displays the populated PDF file. The user then prints their address labels. Do what you want with this, except try to sell it back to me. 🙂

<?php

...

/*** Here's where we create our FDF data  ***/

$fdfdata = "%FDF-1.2n%n";
$fdfdata .= "1 0 obj << /FDF ";
$fdfdata .= "<< /Fields ["; 

$i=1;
$name_array = ifx_fetch_row($seatingCR, "next");
while (is_array($name_array))           /* The PDF file has first ane last name fields  */
{                                       /* fname1, fname2, etc., and lname1, lname2, etc. */
  $fdfdata .= "<< /V (";                /* Set the value of the fdf field */
  $str = chop($name_array["t_fname"]);  /* Get rid of trailing spaces     */
  $fdfdata .= $str;                     /* Print the value                */
  $fdfdata .= ") /T (fname";            /* Print the field title          */
  $fdfdata .= "$i";                     /* Finish the title name          */
  $fdfdata .= ") >> ";                  /* Done with that field           */
  $fdfdata .= "<< /V (";                /* Do same with next field        */
  $str = chop($name_array["t_lname"]);
  $fdfdata .= $str; 
  $fdfdata .= ", ";
  $fdfdata .= ") /T (lname";
  $fdfdata .= "$i";
  $fdfdata .= ") >> ";
  $i++;
  $name_array = ifx_fetch_row($seatingCR, "next");
}  /* end while  */

$fdfdata .= "]n";

$fdfdata .= "/F (http://<address>/pdfs/$filename.pdf) >>";
$fdfdata .= ">>nendobjntrailern<<n/Root 1 0 Rn>>n";
$fdfdata .= "%%EOF";

/*** Now we display the FDF data which causes Acrobat to start  ***/

header ("Content-Type: application/vnd.fdf");
print ($fdfdata);
?>