Closed (fixed)
Project:
Printer, email and PDF versions
Version:
6.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Apr 2012 at 19:54 UTC
Updated:
25 Apr 2012 at 13:31 UTC
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
Comment #1
jcnventuraThe 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.
Comment #2
soulfroysUnfortunately, 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!
Comment #3
jcnventuraOK. 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.
Comment #4
jcnventuraNow 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.
Comment #5
soulfroysRegardless of version, I spoke too soon, in fact the error also occurs when you generate the PDF, so it is critical.
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.
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)
Comment #6
jcnventuraIn 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.
Comment #7
soulfroysI 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:
Thank you very much for your help!
Comment #8
soulfroys@infojunkie (Sheetnode maintainer) said:
Comment #9
soulfroysSorry! Correcting the status to "Fixed" on this side.