lonelydragon
Programmer
hello, all:
i have the following code trying read a pdf file and updated it. but i always ge the error "The file is damaged and could not be repaired". thank you for help.
<?php
header( 'Content-type: application/pdf' );
header( 'Content-Disposition: filename=cert.pdf');
$fileName = 'webCertificate.pdf';
$fp = fopen ($fileName, 'r' );
//read our template into a variable
$outputs = fread($fp, filesize($fileName));
fclose ($fp);
$studentName = "Mary Lee";
$courseCocName = "Information Science";
$completionDate = "May 12,2005";
$certNumber = "2005"; $outputs = pdf_replace("<<studentName>>", "rongke", $outputs);
print $outputs;
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);
}
?>
i have the following code trying read a pdf file and updated it. but i always ge the error "The file is damaged and could not be repaired". thank you for help.
<?php
header( 'Content-type: application/pdf' );
header( 'Content-Disposition: filename=cert.pdf');
$fileName = 'webCertificate.pdf';
$fp = fopen ($fileName, 'r' );
//read our template into a variable
$outputs = fread($fp, filesize($fileName));
fclose ($fp);
$studentName = "Mary Lee";
$courseCocName = "Information Science";
$completionDate = "May 12,2005";
$certNumber = "2005"; $outputs = pdf_replace("<<studentName>>", "rongke", $outputs);
print $outputs;
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);
}
?>