FPDI & TCPDF problems?

whispers picture whispers · Nov 11, 2013 · Viewed 8.7k times · Source

Im having a rather odd problem getting FPDI & TTCPDF php classes to work together.

FPDI: http://www.setasign.com/products/fpdi/about/

TCPDF: http://www.tcpdf.org/

From reading around and even looking at some of the examples given, these should work together NO PROBLEM...

however.. I am getting some conflicts (or something)

This link shows a rather simple & straight forward way to using BOTH the TPDF and TCPDF classes together:

setasign.com/products/fpdi/demos/tcpdf-demo/

I am running this/testing this LOCALLY using WAMP.. and PHP version 5.4.12

<?php
// just require TCPDF instead of FPDF
//require_once 'fpdf/fpdf.php'; //old
require_once('tcpdf/tcpdf.php');
require_once('fpdi/fpdi.php');

class PDF extends FPDI{
}
// initiate FPDI
$pdf = new FPDI();

// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("SRS_blank.pdf");
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 210mm (width of A4)
$pdf->useTemplate($tplIdx, 0, 0, 210, 297);

// now write some text above the imported page

//position table at bottom
$pdf->SetXY(0, 200);
//set table font
$pdf->SetFont('Helvetica');
//set table color
$pdf->SetTextColor(255, 0, 0);
//table html
$html = '<table border="1" cellspacing="2" cellpadding="2">
    <tr>
        <td width="70" rowspan="6">Company Name</td>

    </tr>
    <tr>
       <td rowspan="6"><img src="images/SRS_logo.jpg"></td>
    </tr>
    <tr>
        <td>Name</td>
        <td>Address</td>
        <td>City/State/Zip</td>
        <td>phone/fax</td>
        <td>email</td>
        <td>URL</td>
    </tr>
</table>';
// output the HTML table to pdf overlay
$pdf->writeHTML($html, true, false, true, false, '');

$pdf->Output();
?>

Here are the errors I am now getting when trying to use TCPDF (which has much more robust options for displaying content)

Strict standards: Declaration of FPDF::_putstream() should be compatible with TCPDF::_putstream($s, $n = 0) in C:\wamp\www\projects\PDF_generation\FPDI\fpdi2tcpdf_bridge.php on line 167

and this:

Strict standards: Declaration of FPDF_TPL::SetFont() should be compatible with TCPDF::SetFont($family, $style = '', $size = NULL, $fontfile = '', $subset = 'default', $out = true) in C:\wamp\www\projects\PDF_generation\FPDI\fpdf_tpl.php on line 460

I am stuck on HOW I get a decent dev environment to test and work with these two classes?

Any ideas? all suggestions appreciated.

thanks!

Answer

haiflive picture haiflive · Feb 21, 2014

when overloading function need specify all params (also with default value)

In file fpdi2tcpdf_bridge.php at line 31 set declaration of function

function _putstream($s) {

on

function _putstream($s, $n=0) {

AND in file fpdf_tpl.php at line 275 set declaration of function

public function SetFont($family, $style = '', $size = 0) {

on

public function SetFont($family, $style = '', $size = 0, $fontfile = '', $subset = 'default', $out = true) {