Hi,

maybe looking at this site you could find what you are looking for :

 FPDF

This is a site dedicated to the generation of PDF documents with PHP.


HTH

Sergio






Bev a écrit :

> Hi,
>
> BACKGROUND
> ============
>
> I am looking to create a series of Certificates and Brouchures etc and then
> using the products Print/Acrobat Distiller option save the documents as
> PDF(with some pre-built in <<Name1>>, <<address1>>, <<address2>> variables
> that can be automatically resolved
>
> "on-the fly" using a PHP script using a PDF_REPACE(see below code) option or
> something similar. This then allows me to Create Nice looking
> Brouchures/Certificates etc with "variable <<abc>> markers" before
> converting to PDF so my online user can have "personalised stationary"
> without the need for them to EDIT any of the documents.
>
> My attempts using PHP -> PDF on the fly....
> ===================================
>
> I am looking for guidance on whats the best method and am I on the right
> track without using the long winded PDFLIB functions..
>
> I wonder if you could help(I'm going round in circles!), I a looking to use
> PHP -> PDF, probably with PDF templates instead of actual PDFLIB coding
> techniques.
>
> I have tried to create a simply script(before I move on)which will process a
> "PDF pre-written" template and resolve variables on the fly(without using
> any PDFLIB functions etc). I created a simple script to do this using
> Microsoft RTF but obviously this would only work on PC's where users have
> WORD etc...(I assume)
>
> I have tried myself but keep getting the error msg "The file is damaged and
> could not be repaired" when it trys to load the "amended " PDF file(see the
> sample script below).
>
> By the way, the script works fine if I comment out the PDF_REPLACE option. I
> assume these are causing some type of error?? I tried updating the Acrobat
> prefences/options to not load in a Browser but that just downloaded to my PC
> and the same error message appeared after I double clicked on it...
>
> The PDF template small script is attached as an example.
>
> Rgds
>
> Bev
>
> <?php
>
> set_time_limit( 180 ); // this script can be very slow
>
> //create short variable names
>
> $name = $HTTP_POST_VARS['name'];
>
> $score = $HTTP_POST_VARS['score'];
>
> 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 );
>
> }
>
> if(!$name||!$score)
>
> {
>
> echo '<h1>Error:</h1>This page was called incorrectly';
>
> }
>
> else
>
> {
>
> //generate the headers to help a browser choose the correct application
>
> $date = date( 'F d, Y' );
>
> // open our template file
>
> $filename = 'PHPCertification.pdf';
>
> $fp = fopen ( $filename, 'r' );
>
> //read our template into a variable
>
> $output = fread( $fp, filesize( $filename ) );
>
> header( 'Content-type: application/pdf' );
>
> header( 'Content-Disposition: filename=cert.pdf');
>
> fclose ( $fp );
>
> // replace the place holders in the template with our data
>
> $output = pdf_replace( '<<NAME>>', strtoupper( $name ), $output );
>
> $output = pdf_replace( '<<Name>>', $name, $output );
>
> $output = pdf_replace( '<<score>>', $score, $output );
>
> $output = pdf_replace( '<<mm/dd/yyyy>>', $date, $output );
>
> // send the generated document to the browser
>
> echo $output;
>
> }
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to