Print Invoice Error Magento 1.8, 1.7, 1.6

Magento is so lovely, isn’t it?  Easy to use, industry standard, secure, great features, I could literally go on and on and on.  But what happens when you normally print your invoices to PDF and the feature breaks?

Determine Your Error

In this scenario, the error starts with the following:

Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with Zend_Pdf_FileParserDataSource::__construct() 

and ends with the path of your website and then the file that is the issue.

It will look something similar to:

\public_html\yourwebsite\lib\Zend\Pdf\FileParserDataSource\File.php on line 41

OR

\root\yourwebsite\lib\Zend\Pdf\FileParserDataSource\File.php on line 41

OR

If you work locally, it may look like this

C:\xampp\magento\htdocs\lib\Zend\Pdf\FileParserDataSource\File.php on line 41

 

Once we review this a bit closer, we can understand that due to Magento being on version 1.8 (or older), an issue has occurred    This error is an incompatibility issue between PHP Version 5.4.4 and zend Framwork

This issue can be fixed by adjusting the code in the following file:

lib/Zend/Pdf/FileParserDataSource.php

NOTE:  As always, you should backup your website before any major change.  Also, make sure that you make a copy of the original file before you change it.

Open the file and change –

abstract public function __construct();

to

abstract public function __construct($filePath);

Save the file and clear your Magento website cache.  You will not be able to print your invoices once again.