Fop Code

Submitted by micka on Thu, 05/23/2002 - 2:52am.
    require_once("XML/fo2pdf.php");
//make a pdf from simple.fo and save the pdf in a tmp-folder
$fop = new xml_fo2pdf();

// the following 2 lines are the default settins, so not
// necessary here, but you can set it to other values
$fop->setRenderer("pdf");
$fop->setContentType("application/pdf");

//If you want other fonts in your PDF, you need to declare them in a
// config file. Declare here the path to this file [optional].
// More information about fonts and fop on the apache-fop webpage.
//$fop->setConfigFile("userconfig.xml");

if (PEAR::isError($error = $fop->run("infile.fo")))
{
die("FOP ERROR: ". $error->getMessage());
}

// print pdf to the outputbuffer,
// including correct Header ("Content-type: application/pdf")
$fop->printPDF();

//delete the temporary pdf file
$fop->deletePDF();