Hi all,
another issue. Am using the following code to output to a pedf document.
<?
set_time_limit( 180 ); // this script can be very slow
function pdf_replace( $pattern, $replacement, $string )
{
$len = strlen( $pattern );
$regexp = '';
for ( $i = 0; $i<$len; $i++ )
{
$regexp .= $pattern[$i];
if ($i<$len-1)
$regexp .= "(\)\-{0,1}[0-9]*\(){0,1}";
}
return ereg_replace ( $regexp, $replacement, $string );
}
//generate the headers to help a browser choose the correct application
header( "Content-Disposition: filename=cert.pdf");
header( "Content-type: application/pdf" );
$date = date( "F d, Y" );
$firstname = "David";
$lastname = "Beal";
$certno = "675_bcFg";
// open our template file
$filename = "cert5.pdf";
$fp = fopen ( $filename, "r" );
//read our template into a variable
$output = fread( $fp, filesize( $filename ) );
fclose ( $fp );
// replace the place holders in the template with our data
$output = pdf_replace( "<<NAME>>", $firstname, $output );
$output = pdf_replace( "<<name>>", strtoupper( $lastname ), $output );
$output = pdf_replace( "<<score>>", $certno, $output );
//$output = pdf_replace( "<<mm/dd/yyyy>>", $date, $output );
// send the generated document to the browser
echo $output;
This is code from a book that i have bought. it works fine with the pdf document that was supplied but when i creat one my self it is no good. I have commpression turned off and am outputing in ascii.
Has any one here had any success in generating a pdf document on the fly with php ?
If so how did you go about it ?
Thanks
David