When I try to export a Book page to PDF, I get the following error:
Notice: Undefined offset: 1 in _print_pdf_wkhtmltopdf_version() (line 611 of ... /print/print_pdf/print_pdf.module
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | wkhtmltopdf error.jpg | 142.79 KB | altrugon |
| #9 | undefined_offset-1151176-9.patch | 667 bytes | shawn_smiley |
Comments
Comment #1
maxxer commentedsame problem
Comment #2
blasthaus commentedsub
Comment #3
maxxer commentedhaving better luck with the tcpdf libraries
Comment #4
arafat_aa commentedYes Maxxer,I am using tcpdf tool but the problem is that the borders of the table of the view does not appear in the resulting pdf , any help wil be appreciated
Comment #5
jcnventuraI was unable to reproduce this with the current dev of the print module.. DO you still get this error?
Comment #6
kukle commentedsame error here
Notice: Undefined offset: 1 in _print_pdf_wkhtmltopdf_version() (regel 655 van /.../.../domains/.../public_html/leden/sites/all/modules/print/print_pdf/print_pdf.module).
Comment #7
kukle commentedSet to active
Comment #8
jcnventuraCan you tell me what's the output of "wkhtmltopdf --version" ?
Comment #9
shawn_smiley commentedHere is the output of wkhtmltopdf --version on my mac dev environment:
I've attached a patch that resolved the issue on my machine.
The patch makes the following code change:
The issue seems to be related to having the call to stream_get_contents() as a direct parameter input on the preg_match function. Moving stream_get_contents() so that it assigns to a variable and then use that variable in preg_match() solved the problem.
Comment #10
jcnventuraYes, that happens on some cases where PHP creates a race condition.. I'll try your patch, and see if that helps everyone..
Comment #11
jcnventuraThanks for the patch! Added to git.
Comment #13
altrugon commentedI'm working with the patched version (7.x-1.0-beta1) but I still see this error.
I've downloaded the wkhtmltopdf.app option, extract the entire content and copy it into
print/lib/wkhtmltopdfand this is what I get:Output of wkhtmltopdf --version:
And when I check the result of
$matchesas follow I get and empty array:Comment #14
jcnventuraMy guess is that $matches is empty because $content is probably also empty.. Can you do a dpm of that one, please?
Comment #15
altrugon commentedYou were right jcnventura, $matches is empty too.
I have created an array with all the relevant variables from
function _print_pdf_wkhtmltopdf_version(), please see the attached screen-shot to check out the results.Thank you.
Comment #16
jcnventuraMy guess is that there's something wrong with PHP or the web server configuration that you're not allowed to execute programs.. Also check the error log for any useful info.
Comment #17
altrugon commentedI don't have anything on the error logs except the mentioned error and I gave 777 permission to everything inside the library folder.
What else do you think could be wrong on the server?
Comment #18
jcnventuraWould it be too much to ask you to try this in Linux?
Until Apple offers me a computer capable of running OS X, or allows me to run OS X on any of my existing computers, I simply can't even try to debug this type of problem. And yeah, I know hell will freeze over before they give me one..
Comment #19
Bevan commentedI had this problem on ubuntu when I installed wkhtmltopdf with apt-get, which installed an old, unsupported version of the library.
Comment #20
mausolos commentedThis appears to be my problem, too. Rats. It would be awfully nice if some updated the requirements page to indicate which version(s) of wkhtmltopdf are acceptable.
Comment #21
gianfrasoft commentedSame problem here but with tcpdf library:
Notice: Undefined offset: 1 in theme_print_pdf_tcpdf_header() (linea 503 di mysite\sites\all\modules\contrib\print\print_pdf\print_pdf.pages.inc).
Comment #22
jcnventura@gianfrasoft: I think I got your problem.. Please try the latest dev, when that is created a few hours from now.
Comment #23
jcnventuraNo further info in two weeks. Closing the issue.
Comment #24
jcnventuraComment #25
dtarc commentedI ran into an issue like this. It turns out MAMP doesn't play well with ImageMagick. This is documented here: http://mikepuchol.com/2010/08/26/getting-mamp-1-9-to-work-with-image-mag...
I did step 8 on that page and got pdf generation on mac via wkhtmltopdf to work.
Comment the two lines that set and export the path, which look like:
Comment #26
nibo commentedHi,
I also got the Undefined offset error on theming the tcpd header:
Notice: Undefined offset: 1 in theme_print_pdf_tcpdf_header() (line 514 in /sites/all/modules/print/print_pdf/print_pdf.pages.inc).The thing is, that I did override the print.tpl.php and removed the div with the class = "print-site_name" since I didn't wanted to output the site_name. But the preg_match() in the theme_print_pdf_tcpdf_header() function is looking exactly for this div to generate the $tpl_site_name variable.
Wouldn't it be better to pass the logo, title and site name in the $vars array?
Comment #27
jcnventuraSee #1865562: PDF Templates missing "print-site_name" are generating errors for a patch that avoids the problem
while keeping the current (old) way of preg_match()ing the HTML to get the needed data.. The current code is a lot more template-like, so that info could indeed all be in the $vars array.Looking back at it, the reason it does such a convoluted scheme is to try to make it easy for themers to change the footer and header of the TCPDF pages, simply by modifying the print.tpl.php. The info is already all in the $vars array.
Comment #28
debra-v commentedI've been trying to get this to work on both a MAMP installation and a non-MAMP shared hosting server.
Using :
wkhtmltopdf-i386 (wkhtmltopdf-0.11.0_rc1-static-i386)
Drupal 7.21
Error when attempting access to PDF Version:
Notice: Undefined offset: 1 in _print_pdf_wkhtmltopdf_version() (line 711 of /xxxx/xxxx/public_html/drupal/sites/all/modules/print/print_pdf/print_pdf.module).
I have the latest version of print that includes the update listed above and have attempted several config changes (such as the path adjustment for MAMP)
I have verified permissions to the library are '755' and owned by the correct user.
Print config settings have been setup. The Print module detects the existence of wkhtmltopdf.
Not sure what I'm missing, but I cannot get it to work.
Any Suggestions?
.......
Update: Looks like I did not have the correct binary version. I reinstalled the OS X version and it started working. Will reinstall with a diff version on the shared hosting site and see what happens.
Comment #29
bleen commentedFWIW I had to follow a similar solution to the one in #25 to resolve this error. I guess the more recent versions of MAMP have a slightly different /Applications/MAMP/Library/bin/envvars file... I had
sudo vim /Applications/MAMP/Library/bin/envvarsand change this:to