plodos Posted December 10, 2008 Share Posted December 10, 2008 pdf.php <?php set_time_limit( 90 ); // this script can be very slow //create short variable names $name = "Mamas"; 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' ); // open our template file $filename = 'pdfMake.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>>', strtoupper( $name ), $output ); $output = pdf_replace( '<<mm/dd/yyyy>>', $date, $output ); // send the generated document to the browser echo $output; ?> I want to change the name, you can see the name <<NAME>> variable in the attachment pdf file. When I click the pdf.php file, I got an error "the file is damaged and could not be repaired." what can be the problem ? [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Brian W Posted December 10, 2008 Share Posted December 10, 2008 see comments on http://us.php.net/pdf for a couple libraries that may help. Don't think you can pull what you are trying to do though... but maybe I'm wrong. I'm wrong atleast partially... tested your script without the $output = pdf_replace( '<<NAME>>', strtoupper( $name ), $output ); $output = pdf_replace( '<<mm/dd/yyyy>>', $date, $output ); chunk and it worked. Quote Link to comment Share on other sites More sharing options...
plodos Posted December 11, 2008 Author Share Posted December 11, 2008 // $output = pdf_replace( '<<NAME>>', strtoupper( $name ), $output ); // $output = pdf_replace( '<<mm/dd/yyyy>>', $date, $output ); when I click the pdf.php without these codes, scipt is showing me the pdfMake.pdf but how can I change the <<NAME>> to Mamas ? I need another codes:S pdf_replace() function is not working? what is the solution ways/codes ? Quote Link to comment Share on other sites More sharing options...
Brian W Posted December 11, 2008 Share Posted December 11, 2008 comment those headers out and run the page... then come back and finishing reading. As you can see, you can't find <<NAME>> anywhere... its been made into another language. If you find out which language that is specifically, you may be able to pinpoint the strings that makes that word and the figure out a way to convert given strings into that language. Best of luck Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.