I have a PDF of a blank certificate, I want to fill in two lines when the user completes a course of study, and display the PDF so they can print or download it.
I am using TCPDF to write the two lines on an existing PDF.
Per suggestions in a previous post ( using PHP to fill in a PDF ), I am using TCPDF_IMPORT to bring an existing PDF into the object, and writing on top of it.
However, the original PDF does NOT show on the screen, I am left with a blank document, with only the lines of text I created.
Below is what I have to this point - it yields ONLY the line "This is my test text."
<?php
// Include the main TCPDF library (search for installation path).
require_once( '../tcpdf_import.php' );
// create new PDF document
$pdf = new TCPDF_IMPORT( '1_cert.pdf' );
// set document information
$pdf->SetCreator( 'aaa.com' );
$pdf->SetAuthor( 'aaa.com' );
$pdf->SetTitle( 'Certificate Test' );
$pdf->SetSubject( 'In completion of x-module' );
$pdf->SetKeywords( '' );
// set default monospaced font
$pdf->SetDefaultMonospacedFont( PDF_FONT_MONOSPACED );
// set font
$pdf->SetFont( 'times', 'B', 30 );
// display
$pdf->SetDisplayMode( 'fullpage', 'SinglePage', 'UseNone' );
// set margins
$pdf->SetMargins( 10, PDF_MARGIN_TOP, 10 );
// set auto page breaks
$pdf->SetAutoPageBreak( TRUE, PDF_MARGIN_BOTTOM );
// set image scale factor
$pdf->setImageScale( PDF_IMAGE_SCALE_RATIO );
// set some language-dependent strings (optional)
if ( @file_exists( dirname( __FILE__ ).'/lang/eng.php' ) ) {
require_once( dirname( __FILE__ ).'/lang/eng.php' );
$pdf->setLanguageArray( $l );
}
// -------------------------------------------------------------
// stuff i believe should write test over an existing PDF
// -------------------------------------------------------------
$pdf->StartPage( 'L', '', false );
$pdf->SetY( 50 );
$pdf->Cell( 0, 0, 'test text', 0, 1, 'C' );
$pdf->EndPage( false );
// -------------------------------------------------------------
// end of stuff i believe should write test over an existing PDF
// -------------------------------------------------------------
//Close and output PDF document
$pdf->Output( 'aTest.pdf', 'I' );
?>