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!
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) {
As of the latest version of both FPDI and TCPDF, this strict warning should not be occurring any longer. I don't know which version of FPDI is when they finally started overloading TCPDF's functions correctly, but it appears that the following mixes of PHP, FPDI, and TCPDF do not generate these warnings anymore...
PHP Version: 5.5.10
FPDI Version: 1.5.2 - http://www.setasign.com/products/fpdi/downloads/
TCPDF Version: 6.0.089 - http://sourceforge.net/projects/tcpdf/files/
Related
I've written the following code for merging PDFs using this answer
function merge_pdfs() {
$pdfs_array = array('1.pdf', '2.pdf');
$pdf = new FPDI_Protection();
for ($i = 0; $i < count($pdfs_array); $i++ ) {
$pagecount = $pdf->setSourceFile($pdfs_array[$i]);
for($j = 0; $j < $pagecount ; $j++) {
$tplidx = $pdf->importPage(($j +1), '/MediaBox');
$pdf->addPage('P','A4');
$pdf->useTemplate($tplidx, 0, 0, 0, 0, TRUE);
}
}
$dt = new DateTime(NULL, new DateTimeZone($data->user->timezone));
$pdf->SetTitle('PDF, created: '.$dt->format(MYHMRS_DATETIME_FRIENDLY));
$pdf->SetSubject('PDF subject !');
$output = $pdf->Output('', 'S');
$name = "PDF".'-'.$dt->format('ymd').'.pdf';
$this->output
->set_header("Content-Disposition: filename=$name;")
->set_content_type('Application/pdf')
->set_output($output);
}
So, after this I'm getting the following error message
This document (1.pdf) probably uses a compression technique which is not supported by the free parser shipped with FPDI. (See https://www.setasign.com/fpdi-pdf-parser for more details)
I've checked the link and it suggests to set another PDF Parser ( If I understand right )
But I'm not sure how to make it working with Codeigniter and my example
Should I create library and try to use it?
Or maybe you know another solution for merging PDFs
The issue was related to PDF versions
Edit
If you don't know, the PDFs has versions. Yeah, I was surprised as well. Please check them here PDF versions
So, the problem was that I was trying to merge PDF 1.5 version with PDF 1.6
An example. It is simple.
<?php
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('<h1>Hello world!</h1>');
$mpdf->AddPage('P');
$mpdf->WriteHTML('<h1>More</h1>');
$mpdf->Output();
?>
I am using the mpdf extension in my yii2 site in which the pdf are created.The pdf files are uploaded as an attachment first & then merged using the mpdf, this is working fine for the pdf files of version less than or equals to 1.4 & if i use a pdf file greater than this it gives me the error.I found the posts regarding this too but there is no actual answer its just asked to use the FPDI which also causes this error & i cannot chang my library to any other my whole work is dependent on this mpdf library.The users cannot save there file firstly in lower version & then upload it so please suggest me something i can do with it.
//merge multiple PDF files
$pdf=new mPDF('', 'Letter', 0, '', 8.5, 11);
$pdf->SetImportUse();
if($body !="")
{
$pdf->WriteHTML($body);
$pdf->WriteHTML('<pagebreak />');
}
$body1='<style>#page {margin: 96px;border:1px solid red;}</style>';
$fileArcount = count($multifileArr);
$z=1;
foreach($multifileArr as $fileAr)
{
if($fileAr !="")
{
$dashboard_pdf_file="../web/uploads/".$fileAr;
}
$pagecount = $pdf->SetSourceFile($dashboard_pdf_file);
for ($i=1; $i<=$pagecount; $i++) {
$import_page = $pdf->ImportPage($i);
$pdf->UseTemplate($import_page);
if ($i < $pagecount)
{
//$pdf->AddPage();
$pdf->AddPage('L',80,80,80);
}
}
if($z < $fileArcount){
$pdf->WriteHTML('<pagebreak />');
}
$z++;
}
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' );
?>
Well, not as eloquent as I wanted, but I found something that works....
<?php
require_once "tcpdf/tcpdf.php";
require_once "FPDI/fpdi.php";
$pdf = new FPDI( 'L', 'mm', 'LETTER' ); //FPDI extends TCPDF
$pdf->AddPage();
$pages = $pdf->setSourceFile( 'test.pdf' );
$page = $pdf->ImportPage( 1 );
$pdf->useTemplate( $page, 0, 0 );
$pdf->Output( 'newTest.pdf', 'F' );
?>
Thanks to Simon who posted in http://sourceforge.net/p/tcpdf/discussion/435311/thread/66272894/
I was able to modify this - it entails running two libraries - but it works.
Create a file and call it pdfConcat.php and paste:
<?php
require_once("tcpdf/tcpdf.php");
require_once("fpdi/fpdi.php");
class concat_pdf extends FPDI {
var $files = array();
function setFiles($files) {
$this->files = $files;
}
function concat() {
foreach($this->files AS $file) {
$pagecount = $this->setSourceFile($file);
for ($i = 1; $i <= $pagecount; $i++) {
$tplidx = $this->ImportPage($i);
$s = $this->getTemplatesize($tplidx);
$this->AddPage('P', array($s['w'], $s['h']));
$this->useTemplate($tplidx);
}
}
}
}
?>
Usage:
include_once("pdfConcat.php");
$pdf =& new concat_pdf();
$pdf->setFiles(array("doc.pdf","pauta.pdf", "4bp.pdf", "5bp.pdf"));
$pdf->concat();
$pdf->Output("newpdf.pdf", "I");
http://garridodiaz.com/concatenate-pdf-in-php/
Olè!!!
As stated in TCPDF_IMPORT documentation page at this time (2020-04-16)
TCPDF_IMPORT !!! THIS CLASS IS UNDER DEVELOPMENT !!!
Futhermore the free version of FPDI supports PDF up to version 1.4
If someone else is looking for something that works easily with TCPDF, I used TCPDI from https://github.com/pauln/tcpdi. You can find some fork ready for composer too.
The usage is quite simple and similar to FPDI. Here a snipped from my code. I have a privacy policy (a static PDF file) and want to save a copy with user name and agreement date in the footer of each page.
// Create new PDF document
$pdf = new TCPDI(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
...
// Add the pages from the source file.
$pagecount = $pdf->setSourceFile($localPrivacy);
for ($i = 1; $i <= $pagecount; $i++) {
$tplidx = $pdf->importPage($i);
$pdf->AddPage();
$pdf->useTemplate($tplidx);
// Add agreement text in document footer
$pdf->SetXY(15,282);
$pdf->Cell(180, 5, "Documento approvato da {$fullName} il {$date}", 0, 0, 'C');
}
// Send PDF on output
$pdf->Output(FOLDER_PATH . DIRECTORY_SEPARATOR . "{$userId}.pdf", 'F');
I am using following code
<?php
$hd1 = $_POST["hd1"];
require_once('fpdi.php');
require_once('fpdf.php');
require('tfpdf.php');
$pdf =& new FPDI();
$pagecount = $pdf->setSourceFile('template.pdf');
$tplIdx = $pdf->importPage(1);
$s = $pdf->getTemplatesize($tplIdx);
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L', array($s['w'], $s['h']));
$pdf->useTemplate($tplIdx,0, 0, 0, 0, true);
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->AddFont('DejaVu', 'B', 'DejaVuSansCondensed-Bold.ttf', true);
$pdf->SetFont('DejaVu', '', 14);
$pdf->Cell(50,10,$hd1,0,1);
// Select a standard font (uses windows-1252)
$pdf->SetFont('Arial', '', 14);
$pdf->Ln(10);
$pdf->Write(5, 'The file uses font subsetting.');
$pdf->Output('doc.pdf', 'I');
?>
I am getting error:
Fatal error: Class 'FPDF' not found in C:\xampp\htdocs\san\ak-form\pdf\fpdi_bridge.php on line 33
When I use following code from http://www.setasign.com/products/fpdi/demos/tfpdf-demo/
<?php
$hd1 = $_POST["hd1"];
// require tFPDF
require_once('tfpdf.php');
// map FPDF to tFPDF so FPDF_TPL can extend it
class FPDF extends tFPDF
{
/**
* "Remembers" the template id of the imported page
*/
protected $_tplIdx;
/**
* Draw an imported PDF logo on every page
*/
public function Header()
{
if (is_null($this->_tplIdx)) {
$this->setSourceFile("template.pdf");
$this->_tplIdx = $this->importPage(1);
}
$size = $this->useTemplate($this->_tplIdx, 130, 5, 60);
$this->SetFont('DejaVu', 'B', 16);
$this->SetTextColor(0);
$this->SetXY($this->lMargin, 5);
$text = 'tFPDF (v' . tFPDF_VERSION . ') and FPDI (v'
. FPDI::VERSION . ')';
$this->Cell(0, $size['h'], $text);
$this->Ln();
}
}
// just require FPDI afterwards
require_once('fpdi.php');
// initiate PDF
$pdf = new FPDI();
// Add some Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu', '', 'DejaVuSansCondensed.ttf', true);
$pdf->AddFont('DejaVu', 'B', 'DejaVuSansCondensed-Bold.ttf', true);
// add a page
$pdf->AddPage();
$pdf->SetFont('DejaVu', '', 14);
// Select a standard font (uses windows-1252)
$pdf->SetFont('Arial', '', 14);
$pdf->Ln(10);
$pdf->Write(5, 'The file uses font subsetting.');
$pdf->Output('doc.pdf', 'I');
?>
And getting following error:
Warning: fopen(/home/content/w/i/s/wiseinmotion/html/test3/pdf/font/unifont/DejaVuSansCondensed.ttf): failed to open stream: No such file or directory in C:\xampp\htdocs\san\ak-form\pdf\font\unifont\ttfonts.php on line 496
Can't open file /home/content/w/i/s/wiseinmotion/html/test3/pdf/font/unifont/DejaVuSansCondensed.ttf
What is the correct way so that I can use exiting pdf and can use utf-8 font?
You're asking two different questions here:
why isn't FPDF defined in the first code sample, and
why can't it load my font in the second code sample.
I'm going to answer #2 first, because it's easy: the font file is not being found. Check your path and make sure the code is looking for the font in the right place.
Regarding #1: I suspect the issue comes down to your require_once statements. Specifically, you're requiring fpdf.php in your code when the example code does not. My guess is that there's a conflict there somewhere.
Rather than spending a lot of time looking around the libraries for a problem, I would start with the example code (which comes from the developer's website, so we're pretty sure it works - maybe not, but let's assume it does until proven otherwise). Assuming that code works (and all you need to do there is fix the path to your font), start with that and modify it to do what you want.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
My concept is - there are 10 pdf files in a website. User can select some pdf files and then select merge to create a single pdf file which contains the selected pages. How can i do this with php?
Below is the php PDF merge command.
$fileArray= array("name1.pdf","name2.pdf","name3.pdf","name4.pdf");
$datadir = "save_path/";
$outputName = $datadir."merged.pdf";
$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName ";
//Add each pdf file to the end of the command
foreach($fileArray as $file) {
$cmd .= $file." ";
}
$result = shell_exec($cmd);
I forgot the link from where I found it, but it works fine.
Note: You should have gs (on linux and probably Mac), or Ghostscript (on windows) installed for this to work.
i suggest PDFMerger from github.com, so easy like ::
include 'PDFMerger.php';
$pdf = new PDFMerger;
$pdf->addPDF('samplepdfs/one.pdf', '1, 3, 4')
->addPDF('samplepdfs/two.pdf', '1-2')
->addPDF('samplepdfs/three.pdf', 'all')
->merge('file', 'samplepdfs/TEST2.pdf'); // REPLACE 'file' WITH 'browser', 'download', 'string', or 'file' for output options
I've done this before. I had a pdf that I generated with fpdf, and I needed to add on a variable amount of PDFs to it.
So I already had an fpdf object and page set up (http://www.fpdf.org/)
And I used fpdi to import the files (http://www.setasign.de/products/pdf-php-solutions/fpdi/)
FDPI is added by extending the PDF class:
class PDF extends FPDI
{
}
$pdffile = "Filename.pdf";
$pagecount = $pdf->setSourceFile($pdffile);
for($i=0; $i<$pagecount; $i++){
$pdf->AddPage();
$tplidx = $pdf->importPage($i+1, '/MediaBox');
$pdf->useTemplate($tplidx, 10, 10, 200);
}
This basically makes each pdf into an image to put into your other pdf. It worked amazingly well for what I needed it for.
$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=".$new." ".implode(" ", $files);
shell_exec($cmd);
A simplified version of Chauhan's answer
Both the accepted answer and even the FDPI homepage seem to give botched or incomplete examples. Here's mine which works and is easy to implement. As expected it requires fpdf and fpdi libraries:
FPDF: http://www.fpdf.org/en/download.php
FPDI: https://www.setasign.com/products/fpdi/downloads
require('fpdf.php');
require('fpdi.php');
$files = ['doc1.pdf', 'doc2.pdf', 'doc3.pdf'];
$pdf = new FPDI();
// iterate over array of files and merge
foreach ($files as $file) {
$pageCount = $pdf->setSourceFile($file);
for ($i = 0; $i < $pageCount; $i++) {
$tpl = $pdf->importPage($i + 1, '/MediaBox');
$pdf->addPage();
$pdf->useTemplate($tpl);
}
}
// output the pdf as a file (http://www.fpdf.org/en/doc/output.htm)
$pdf->Output('F','merged.pdf');
I've had similar problem in my software. We've wanted to merge several PDF files into one PDF file and submit it to an outer service. We've been using the FPDI solution as shown in Christa's solution.
However, the input PDF's we've been using could be in version higher than 1.7. We've decided to evaluate the FPDI commercial add-on. However, it turned out that some of the documents scanned by our office copier were having malformed indexes, which crashed the commercial FPDI add-on. So we've decided to use Ghostscript solution as in Chauhan's answer.
But then we got some strange metadata in the output PDF properties.
Finally we've decided to join two solutions to get PDF's merged and downgraded by Ghostscript, but the metadata is set by FPDI. We don't know yet how it would work with some advanced formatted pdfs, but for scans we use it works just fine. Here's our class excerpt:
class MergedPDF extends \FPDI
{
private $documentsPaths = array();
public function Render()
{
$outputFileName = tempnam(sys_get_temp_dir(), 'merged');
// merge files and save resulting file as PDF version 1.4 for FPDI compatibility
$cmd = "/usr/bin/gs -q -dNOPAUSE -dBATCH -dCompatibilityLevel=1.4 -sDEVICE=pdfwrite -sOutputFile=$outputFileName";
foreach ($this->getDocumentsPaths() as $pdfpath) {
$cmd .= " $pdfpath ";
}
$result = shell_exec($cmd);
$this->SetCreator('Your Software Name');
$this->setPrintHeader(false);
$numPages = $this->setSourceFile($outputFileName);
for ($i = 1; $i <= $numPages; $i++) {
$tplIdx = $this->importPage($i);
$this->AddPage();
$this->useTemplate($tplIdx);
}
unlink($outputFileName);
$content = $this->Output(null, 'S');
return $content;
}
public function getDocumentsPaths()
{
return $this->documentsPaths;
}
public function setDocumentsPaths($documentsPaths)
{
$this->documentsPaths = $documentsPaths;
}
public function addDocumentPath($documentPath)
{
$this->documentsPaths[] = $documentPath;
}
}
The usage of this class is as follows:
$pdf = new MergedPDF();
$pdf->setTitle($pdfTitle);
$pdf->addDocumentPath($absolutePath1);
$pdf->addDocumentPath($absolutePath2);
$pdf->addDocumentPath($absolutePath3);
$tempFileName = tempnam(sys_get_temp_dir(), 'merged');
$content = $pdf->Render();
file_put_contents($tempFileName, $content);
I have tried similar issue and works fine, try it. It can handle different orientations between PDFs.
// array to hold list of PDF files to be merged
$files = array("a.pdf", "b.pdf", "c.pdf");
$pageCount = 0;
// initiate FPDI
$pdf = new FPDI();
// iterate through the files
foreach ($files AS $file) {
// get the page count
$pageCount = $pdf->setSourceFile($file);
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size['w'] > $size['h']) {
$pdf->AddPage('L', array($size['w'], $size['h']));
} else {
$pdf->AddPage('P', array($size['w'], $size['h']));
}
// use the imported page
$pdf->useTemplate($templateId);
$pdf->SetFont('Helvetica');
$pdf->SetXY(5, 5);
$pdf->Write(8, 'Generated by FPDI');
}
}
This worked for me on Windows
download PDFtk free from https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
drop folder (PDFtk) into the root of c:
add the following to your php code where $file1 is the location and name of the first PDF file, $file2 is the location and name of the second and $newfile is the location and name of the destination file
$file1 = ' c:\\\www\\\folder1\\\folder2\\\file1.pdf';
$file2 = ' c:\\\www\\\folder1\\\folder2\\\file2.pdf';
$file3 = ' c:\\\www\\\folder1\\\folder2\\\file3.pdf';
$command = 'cmd /c C:\\\pdftk\\\bin\\\pdftk.exe '.$file1.$file2.$newfile;
$result = exec($command);
I created an abstraction layer over FPDI (might accommodate other engines).
I published it as a Symfony2 bundle depending on a library, and as the library itself.
The bundle
The Library
usage:
public function handlePdfChanges(Document $document, array $formRawData)
{
$oldPath = $document->getUploadRootDir($this->kernel) . $document->getOldPath();
$newTmpPath = $document->getFile()->getRealPath();
switch ($formRawData['insertOptions']['insertPosition']) {
case PdfInsertType::POSITION_BEGINNING:
// prepend
$newPdf = $this->pdfManager->insert($oldPath, $newTmpPath);
break;
case PdfInsertType::POSITION_END:
// Append
$newPdf = $this->pdfManager->append($oldPath, $newTmpPath);
break;
case PdfInsertType::POSITION_PAGE:
// insert at page n: PdfA={p1; p2; p3}, PdfB={pA; pB; pC}
// insert(PdfA, PdfB, 2) will render {p1; pA; pB; pC; p2; p3}
$newPdf = $this->pdfManager->insert(
$oldPath, $newTmpPath, $formRawData['insertOptions']['pageNumber']
);
break;
case PdfInsertType::POSITION_REPLACE:
// does nothing. overrides old file.
return;
break;
}
$pageCount = $newPdf->getPageCount();
$newPdf->renderFile($mergedPdfPath = "$newTmpPath.merged");
$document->setFile(new File($mergedPdfPath, true));
return $pageCount;
}
myokyawhtun's solution worked best for me (using PHP 5.4)
You will still get an error though - I resolved using the following:
Line 269 of fpdf_tpl.php - changed the function parameters to:
function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='',$align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0) {
I also made this same change on line 898 of fpdf.php