I had this error (last DEV) when accessing the menu: admin/reports/status

The conflict is with the PHPExcel library (http://phpexcel.codeplex.com). This library is used by Sheetnode module in "sites/all/libraries/PHPExcel/Classes/PHPExcel/Shared/PDF/tcpdf.php". Disable the module "Sheetnode PHPExcel" fixes the error, but this is not an option for me... : (

Thanks in advance!

Comments

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

The print_pdf module needs to include TCPDF at that point, to find out it's version number. It seems PHPExcel is also including TCPDF at that page - possibly always.

The only way to solve this would be to use namespaces to keep them separate. However, I don't have time to setup such a complicated scenario as the one you have. If you know enough PHP you should be able to create a print_pdf namespace in which the TCPDF class can be instanciated.

If you solve it, please share the patch.

soulfroys’s picture

Unfortunately, namespace is only for PHP> = 5.3.0 :(
Anyway, I opened an issue in Sheetnode module (#1513390: Fatal error: Cannot redeclare class TCPDF in sites/all/libraries/tcpdf/tcpdf.php on line 155 (conflict with the print module)), to see if they can help us solve this critical conflict.

Thank you for your attention!

jcnventura’s picture

OK. So namespaces are out..

Another possiblity is to use the TCPDF version that is included with PHPExcel. The print_pdf module does use require_once to include the tcpdf.php file, so as long as PHPExcel does the same, the redeclaration problem does not exist.

Since you're already placing that in sites/all/libraries, the print_pdf module should be able to find that tcpdf.php and use it.. Now of course the problem is that the module currently requires TCPDF >= 5.9.012 and the version included in PHPExcel 1.7.6 is 5.9.009..

I think it only requires that version because TCPDF's author changed the way to find the version number in a non-trivial way, and I didn't bother to make a mechanism to find the lower versions. but the real functionality of print_pdf itself should be fine with 5.9.009, so as long as you are OK with the error with the status report.

There's very little that can be done on this side, that it doesn't already do.

jcnventura’s picture

Now that I talked about it, I bothered enough to add support for the old method of finding the TCPDF version.

As long as PHPExcel also uses include_once/require_once, you shouldn't have any more problems.

soulfroys’s picture

but the real functionality of print_pdf Itself Should Be fine with 5.9.009, so as long as you are OK with the error with the status report.

Regardless of version, I spoke too soon, in fact the error also occurs when you generate the PDF, so it is critical.

Another possiblity is to use the TCPDF version that is included with PHPExcel.

Yes, I chose this option in "admin/settings/print/pdf":
(x) sites/all/libraries/PHPExcel/Classes/PHPExcel/Shared/PDF/tcpdf.php

Well... now gave another error:
TCPDF ERROR: [Image] Unable to get image: /opt/lampp/htdocs/intranet/sites/all/libraries/PHPExcel/Classes/PHPExcel/Shared/PDF/images/http:///intranet/sites/default/files/tmp/print_logo.png

Does this still relates to the Print Module? It seems a path issue...
Note: Printer-friendly version generates smoothly, including the print_logo.png image.

There's very little That Can Be done on this side

Dude, you've done a lot! Thanks for your help. I really appreciate it.

(English is not my native language, so forgive me for all mistakes)

jcnventura’s picture

In the pdf settings there's a checkbox to enable local file access for images.. Try to use that, it may solve your problem. I guess that the print_pdf auto-config can't kick in as PHPExcel starts the TCPDF class before. Other than that, this is starting to look as print_pdf (using TCPDF) and PHPExcel are incompatible.

If local file access doesn't solve it, the only other solution is to switch to dompdf or wkhtmltopdf.

soulfroys’s picture

I tried to use "local file access" but did not work.

As I said before, the problem now is the path to the logo, as I need it, I disable the module Sheetnode PHPExcel library for now. The Print module is more important to me right now... :)

Anyway, the new version of PHPExcel library (1.7.8) will come with better support for PDF:

BREAKING CHANGE! In previous versions of PHPExcel library up to and including 1.7.7,
the 3rd-party library TCPDF was bundled with PHPExcel library for rendering PDF files
through the PDF Writer.

PHPExcel library From 1.7.8 onwards, this will no longer be the case. The PDF Writer is
Being rewritten to allow the choice of 3rd party PDF libraries (TCPDF, mPDF, and
dompdf INITIALLY), none of Which Will be bundled with PHPExcel library, but Which Can
be downloaded seperately from the Appropriate sites. Selection of the library to
be used, and the path to directory That library will be defined through PHPExcel library
configuration settings, Allowing more flexibility.

Thank you very much for your help!

soulfroys’s picture

Title: Fatal error: Cannot redeclare class TCPDF in sites/all/libraries/tcpdf/tcpdf.php on line 155 » Fatal error: Cannot redeclare class TCPDF in sites/all/libraries/tcpdf/tcpdf.php on line 155 (Sheetnode module conflict)
Status: Postponed (maintainer needs more info) » Closed (fixed)

@infojunkie (Sheetnode maintainer) said:

I will rework this dependency to decouple it from PHPExcel, and to try to make it compatible with the Print module.

soulfroys’s picture

Status: Closed (fixed) » Fixed

Sorry! Correcting the status to "Fixed" on this side.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.