After upgrading from previous version 5.x-4.8 to newest version 4.9 the pdf generation don't work any longer.

I encountered the following message in the watchdog log:

wkhtmltopdf Xvfb: error opening security policy file /etc/X11/xserver/SecurityPolicy Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list! Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list! Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list! Could not init font path element /usr/share/fonts/X11/Type1, removing from list! Could not init font path element /usr/share/fonts/X11/100dpi, removing from list! Could not init font path element /usr/share/fonts/X11/75dpi, removing from list! Could not init font path element /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType, removing from list!

I'm using the latest wkhtmltopdf and the Xvfb executable on my linux machine. On ubuntu 8.04 all the files/dirs mentioned in the watchdog log entry just don't exist.

After downgrading back to print 5.x-4.8 everything works fine again.

Anyone any idea's? Or just a bug in the code?

Comments

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Is your server running on Windows?

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Active

Forget my previous comment.. Of course Ubuntu isn't Windows..

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

I've looked at the differences in the PDF module between 5.x-4.8 and 5.x-4.9, and unless you're on Windows, the module is virtually the same. The only other related change was the support for tokens in the wkhtmltopdf options string.

Can you please reinstall 5.x-4.9 and reconfigure the PDF settings to make sure that it can find your wkhtmltopdf executable?

João

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

No further info in two weeks. Closing the issue.

digidoo’s picture

Has anyone solved this problem yet?

I'm running drupal 6 on ubuntu with the distro's xvfb and have the same issues.
In print v6.1.8 everything works fine, upgrading to module v6.1.9 or v6.1.10 brings up the errors.

jcnventura’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

Is it possible that Ubuntu includes "Win" in the PHP_OS variable?

Can you check the value of that variable in Ubuntu, please?

digidoo’s picture

No, that's not the case. The following code reveals Linux as PHP_OS value:

<?
echo PHP_OS;
?>

I run both Drupal 5 and 6 sites on different machines and they all have the same problems with the print module from version 5.x-4.9 and 6.x-1.9 on.

jcnventura’s picture

Thanks for letting me know.. The only other possible problem would be the token module use that was introduced in the same version.

Do you have the token module enabled and installed? If so, can you disable it and test if wkhtmltopdf works again?

João

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

No further info in two weeks. Closing the issue.

digidoo’s picture

Hi João,

I've been too busy to test this earlier. Now i did, installed print v6.1.10 and disabled the Token module, but the symptoms stay the same. No pdf is generated, the following errors in the drupal log:

wkhtmltopdf: Loading page: 10% Loading page: 11% Loading page: 13% Loading page: 16% Loading page: 21% Loading page: 29% Loading page: 100% Failed loading page

and

wkhtmltopdf Xvfb: error opening security policy file /etc/X11/xserver/SecurityPolicy Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list! Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list! Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list! Could not init font path element /usr/share/fonts/X11/Type1, removing from list! Could not init font path element /usr/share/fonts/X11/100dpi, removing from list! Could not init font path element /usr/share/fonts/X11/75dpi, removing from list! [config/hal] couldn't initialise context: (null) ((null)) FreeFontPath: FPE "/usr/share/fonts/X11/misc" refcount is 2, should be 1; fixing.

Back to v6.x-1.9 everything works again, without any error messages.

--Dick

digidoo’s picture

Status: Closed (fixed) » Active

active...

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Did you say 6.x-1.9 in #10 correctly?? Or is it really 6.x-1.8?

João

jcnventura’s picture

I've just finished looking up the code diff between 1.9 and 1.10 and 1.8 and 1.10 and except for the stuff I have already asked about, there's no change that I can see that would make wkhtmltopdf start but then fail to generate the PDF.

Short of installing Ubuntu (which sorry to say, but I am a long-time user of SuSE, so it's out of the question), I am at a dead-end for this.

digidoo’s picture

Hi there,

sorry, my mistake, version 1.8 works, new versions don't.
I solved all issues concerning missing Security Files and fonts on ubuntu. Now, with version 1.10 I get the following errors in Drupal log:

wkhtmltopdf: Loading page: 10% Loading page: 11% Loading page: 11% Loading page: 13% Loading page: 15% Loading page: 21% Loading page: 26% Loading page: 100% Failed loading page
wkhtmltopdf Xvfb: [config/hal] couldn't initialise context: (null) ((null))

Switched back to version 1.8 which does generate the pdf file perfectly, but in Drupal log again:

wkhtmltopdf: Loading page: 10% Loading page: 11% Loading page: 13% Loading page: 16% Loading page: 21% Loading page: 29% Loading page: 100% Waiting for redirect Outputting pages Printing page: 1 Done
wkhtmltopdf Xvfb: [config/hal] couldn't initialise context: (null) ((null)) FreeFontPath: FPE "/usr/share/fonts/X11/misc" refcount is 2, should be 1; fixing.

On my Ubuntu system executing Xvfb :0 on commandine brings up
wkhtmltopdf Xvfb: [config/hal] couldn't initialise context: (null) ((null)) FreeFontPath: FPE "/usr/share/fonts/X11/misc" refcount is 2, should be 1; fixing.

Executing wkhtmltopdf www.google.com google.pdf or whatever just works fine.

What is changed from version 6.x-1.8 to 1.9? Is it related to Token?
What do you think, should I switched to TCPDF? SuSE is a no go for me...

Cheers,
Dick

digidoo’s picture

Stopping dbus (/etc/init.d/dbus stop) solves the hal error on Ubuntu when using Xvfb.
I would say, Ubuntu-wise the module should work.

jcnventura’s picture

Title: pdf generation with wkhtmltopdf on ubuntu doesn't work » wkhtmltopdf on ubuntu doesn't work
Version: 5.x-4.9 » 6.x-1.10
Status: Postponed (maintainer needs more info) » Active

There were several minor changes, but regarding PDF, there were only two: support for wkhtmltopdf in Windows and tokens in the wkhtmltopdf command line.

I looked at all of them, and as I said, nothing that should/could cause any problem. There must indeed be some problem, somewhere. Somebody with Ubuntu needs to figure this out, but it ain't me. Regarding TCPDF, it's a lot worse than wkhtmltopdf. If I were you, I would stick with 1.8 until that someone shows up.

manuel.adan’s picture

Hi,

I got a similar error in my site, I solved it removing some javascript code from the pdf.tpl, wkhtmltopdf fails if a javascript error occurs while loading the page (e.g. in onload event).

digidoo’s picture

Hi adan!

Which file exactly did you modify? Inside the print module folder or your theme folder?

afox’s picture

I think I solved the problem.

It was actually as adan said in #17: in print.tpl.php there is a

  <body<?php print $print['sendtoprinter']; ?>>

Remove the php -statement and you're good to go. First I didn't find any javascipt errors, but by finding this, I noticed that there was

onload='window.print();window.close();'

coming from that php-statement. I think this should apply only to the printer-friendly -pages. So either a check in the preprocess -function or a separate template-file should do as a fix.

willieseabrook’s picture

I confirm the solution by @repolainen in #19.

I'm using wkhtmltopdf on Ubuntu.

When clicking on the print button to print to pdf, the following error message was being logged:

wkhtmltopdf: Loading pages (1/5) [> ] 0% [======> ] 10% [======> ] 11% [=======> ] 13% [=========> ] 16% [============> ] 21% [============================================================] 100% Error: Failed loading page file:///tmp/wktemp-37361d21-798f-4e5c-9a79-c9ebf63a5f37.html Segmentation fault

by replacing

<body<?php print $print['sendtoprinter']; ?>>

in /modules/print/print.tpl.php with:

<body>

it worked.

Thanks @repolainen!!!

jmary’s picture

The issue is the same with Debian server (V5.0.4) :

wkhtmltopdf Xvfb: error opening security policy file /etc/X11/xserver/SecurityPolicy (EE) XKB: Couldn't open rules file /usr/share/X11/xkb/rules/base Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list! Could not init font path element /usr/share/fonts/X11/100dpi/:unscaled, removing from list! Could not init font path element /usr/share/fonts/X11/75dpi/:unscaled, removing from list! Could not init font path element /usr/share/fonts/X11/Type1, removing from list! Could not init font path element /usr/share/fonts/X11/100dpi, removing from list! Could not init font path element /usr/share/fonts/X11/75dpi, removing from list! [config/hal] couldn't initialise context: (null) ((null)

I also did what is said at #19 and it didn't solve. Anyway, the pdf is generated and I can open it.

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

I've disabled the sendtoprinter Javascript in the PDF version. This should fix this problem. Please try the latest dev and see if that fixes your problem.

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

No further info in more than two weeks. Closing the issue.