I have succesfully used an image as a background and added extra data. This is very much what I needed for my site but can be adapated for other solutions - for example gift vouchers or gift certificates.
All the changes are made to delivery.pdf.php starting around line 350 (the end of the invoice page).
Note I am using the latest TCPDF package 5.0.004, Virtuemart 1.1.4 and J! 1.5.17
Code: Select all
// remove default header/footer
/* This gets rid of the Invoice header and footer
* I have not found a way of re-introducing another header
* as it can't be re-declared
*/
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
//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
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
/* I needed to bring in the customer name, as well as the width and length of the product*/
$db4 = new ps_DB;
$q = "SELECT product_id ".
"FROM #__{vm}_order_item ".
"WHERE order_id = ".$d['order_id'];
$db4->query($q);
$db4->next_record();
$prod_id = $db4->f('product_id');
$db5 = new ps_DB;
$q = "SELECT product_length, product_width ".
"FROM #__{vm}_product ".
"WHERE product_id = ".$prod_id;
$db5->query($q);
$db5->next_record();
$north = $db5->f('product_length');
$west = $db5->f('product_width');
$pdf->AddPage('L', 'A4');
// set JPEG quality
$pdf->setJPEGQuality(100);
// Image example - the image needs to be in the general images folder of your Joomla instalation
$pdf->Image('../images/cert6.jpg', 10, 0, 280, 220, '', 'http://www.tcpdf.org', '', true, 150);
//To get elements in their place I use the SetX and SetY Methods
$pdf->SetX(10);
$pdf->SetFont( $pdfFont, "", 20 );
$pdf->Cell(40, 100, 'ASUNCION, '.vmFormatDate($db->f("cdate"), "%d. %B %Y"), 0, 0, 'L');
$pdf->SetX(10);
$pdf->Cell(0, 130, 'OUR EARTH SHARE S.A. CERTIFES THE OWNERSHIP OF THE PLOT', 0, 0, 'L');
$pdf->SetX(10);
$pdf->Cell(0, 145, 'LOCATED WITH SATELLITE COORDINATES', 0, 0, 'L');
$pdf->SetX(10);
$pdf->Cell(0, 160, 'NORTH '.$north.' AND WEST '.$west. 'TO', 0, 0, 'L');
$pdf->SetX(10);
$pdf->SetFont( $pdfFont, "", 40 );
$pdf->Cell(0,200,$dbst->f("first_name") .' '. $dbst->f("middle_name").' '.$dbst->f("last_name"),0,0,'L');
//End certificate
//Start contract
$pdf->AddPage('P', 'A4');
// Resolve the country name from the country code
$db6 = new ps_DB;
$q = "SELECT country ".
"FROM #__{vm}_order_user_info ".
"WHERE order_id = ".$d['order_id'];
$db6->query($q);
$db6->next_record();
$country_cod = $db6->f('country');
$country = $dbst->f("country");
$dbc = new ps_DB;
$dbc->query( "SELECT country_name FROM #__{vm}_country WHERE country_3_code = '$country_cod'");
$dbc->next_record();
$country_name = $dbc->f("country_name");
$cellheader='<strong>PRIVATE AGREEMENT – SALE OF REAL ESTATE <br /><br /><br /></strong>';
$cellcontent ='Being the' .vmFormatDate($db->f("cdate"), "%d. %B %Y"). '<br />ONE OF THE PARTIES, the corporation YOUR EARTH SHARE S.A. with corporate domicile in Montevideo, Uruguay, registered on the Registry of Commerce of Uruguay under the registration number 10941.
<br /><br />THE OTHER PARTY, Mr./Ms.'.$dbst->f("first_name") .' '. $dbst->f("middle_name").' '.$dbst->f("last_name").', domiciled at '.$dbst->f("address_1") .' '. $dbst->f("address_2").' '.$dbst->f("zip").' '.$dbst->f("city").' '.$country_name.'.<br /><br />All of the appearing parties are able, and agree to execute this contract of PRIVATE UNDERTAKING OF PURCHASE AND SALE OF REAL ESTATE, which will be governed under the following clauses and conditions:
<br /><br /><strong>FIRST <br /></strong>The corporation YOUR EARTH SHARE S.A. commits and undertakes to transfer in favor of Mr. /Ms.'.$dbst->f("first_name") .' '. $dbst->f("middle_name").' '.$dbst->f("last_name").', a real estate property of their own, with everything that is built, nailed and planted, located in the district of Chaco, Paraguay, comprising the following satelite coordinates: North'.$north.' and West '. $west. '.
.
.
.
.
<br><br><strong>EIGHTH <br /></strong>The parties submit to the jurisdiction of the ordinary courts of Asuncion, Republic of Paraguay, waiving any other jurisdiction or laws, and establish their domiciles at the places already specified herewith, at which locations will be valid and effective any type of notices formalized by the parties, the same as if they were personally made. <br />In evidence of conformity and acceptance of all the above-mentioned clauses, the parties subscribe in two copies of the same and sole tenor and effect.';
$pdf->SetMargins("10.0","10.0");
$pdf->SetFont( $pdfFont, "", 15 );
$pdf->writeHTML($cellheader, true, 0, true, 0);
$pdf->Sety(10);
$pdf->SetFont( $pdfFont, "", 11 );
$pdf->writeHTML($cellcontent, true, 0, true, 0);
$pdf->lastPage();
// End extra pages
Works for what I need......