I am using Printer-friendly pages module, alongside TCPDF on Drupal 6 running on PHP4/Apache2. The installation goes fine, but when I try to generate a PDF using the link on pages, it gives the following error:
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/content/o/n/l/onlineventure/html/sites/all/modules/print/print_pdf.class.inc on line 12
I have checked all settings, tried installing TCPDF files in "sites/all/modules/print/tcpdf" as well as "sites/all/modules/print" but neither works. I keep getting the above error.
Appreciate any help!
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | print_pdf.class_php4.patch | 1.53 KB | jcnventura |
Comments
Comment #1
jcnventuraHi,
When I created that class (to be able to theme the footer), I made it PHP5-only.. I will try to see what I can do to make it PHP version neutral, as PHP5 is irrelevant here.
João
Comment #2
jcnventuraInstead of making it version neutral, I ended up creating two versions of the class file.. This leaves space to use PHP5 features in the class.
Can you please try the attached patch and tell me if it solved your problem?
João
Comment #3
francwalter commentedI got the same error.
Now (with the patch, the removing of public-instructions or replacing by var) there is no more error, i get a PDF, but this PDF is empty. There is only one horizontal line at the top.
Maybe there are more PHP5-key words in this print-module?
Comment #4
jcnventuraHi,
Thanks for the review. I have committed the code, which will be in the newest dev version in a few hours..
Please try it and tell me if you're still unable to view the PDF.
João
Comment #5
francwalter commentedNow i have an error:
Fatal error: menu_execute_active_handler(): Failed opening required 'sites/all/modules/print/print.pdf.inc' (include_path='.;c:\php4\pear') in C:\apache\Apache2\htdocs\drupal\includes\menu.inc on line 344
Did you test your new version?
Anyway, the older version gives me an empty PDF with only one horizontal line at the top. Why this? Whats wrong there?
I use the tcpdf_4_0_020_php4 (the newest version of tcpdf for PHP4).
Is it whatsoever possible to get pdf with the print module in PHP4?
Comment #6
jcnventuraI have changed some module's paths.. Go to admin/build/modules and press Save Configuration to rebuild the menus, and this problem will go away.
I have to add a menu_rebuild in the install file now that I think of it.
João
Comment #7
hsaleem commentedHi,
Thanks for the patch, João (I still have trouble getting the "ã" on my keboard, so I just pasted your name!) :)
I guess I will have some trouble patching the file, as I don't have shell access to my server (stuck with GoDaddy shared hosting). Anyway, if only you could tell me what functions/vars you have patched, I could implement it myself into the file.
Anyway, I will revert with my trial report!
Hasnain
Comment #8
hsaleem commentedUpdate:
I tried the new dev version, posted on 2008-Aug-22. Updated everything, and gave it a shot. I still get the same error:
The line number has changed, though.
Comment #9
jcnventuraHi,
Can you please re-check the update you did? It's impossible for the code to still be calling that class file if you're using PHP4.
João
Comment #10
hsaleem commentedHi,
Here's the update:
I disabled the Print module, uninstalled it and then removed all files from the sites/all/modules/print folder. After that, downloaded and installed the latest dev version published on 22 Aug 08. Then, I downloaded and installed TCPDF for PHP4. After configuring all the details, this is the new error that I get:
I will investigate further and report.
Hasnain
Comment #11
hsaleem commentedHi,
I did some digging and found out that the function
stripos()is PHP5 only, so the problem lies with TCPDF. They have used PHP5 functions in TCPDF_PHP4 and hence the error. Replacing all occurences ofstripos()withstrpos()in the filetcpdf.phpresolves the issue.More info on the above functions is available @ http://www.php.net/stripos.
There is a new issue however. The generated PDF files have noting but a black horizontal line at the top. I'm using the default
print.csssupplied with the module.Hasnain
Comment #12
jcnventuraI think this fixes the original issue.. The empty PDF is something I need to investigate (I've never installed the PHP4 version of TCPDF), but we can discuss that in it's own issue (#298654: print module creates empty PDF (with TCPDF)).
Joao
Comment #13
jcnventuraComment #14
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.