Closed (fixed)
Project:
Printer, email and PDF versions
Version:
6.x-1.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
16 Dec 2008 at 15:40 UTC
Updated:
21 Dec 2010 at 13:48 UTC
I can't get PDF creation to work with pages that have images. What happens is:
(This is with PHP5).
With dompdf (0.5.1), creating a PDF results in the following error messages in the log:
DOMXPath::query() [<a href='function.DOMXPath-query'>function.DOMXPath-query</a>]: Invalid expression in /my/site/drupal/modules/print/dompdf-0.5.1/include/stylesheet.cls.php on line 573.
DOMXPath::query() [<a href='function.DOMXPath-query'>function.DOMXPath-query</a>]: Invalid expression in /my/site/drupal/modules/print/dompdf-0.5.1/include/stylesheet.cls.php on line 573.
Invalid argument supplied for foreach() in /my/site/drupal/modules/print/dompdf-0.5.1/include/stylesheet.cls.php on line 575.
sprintf() [<a href='function.sprintf'>function.sprintf</a>]: Too few arguments in /my/site/drupal/modules/print/dompdf-0.5.1/include/attribute_translator.cls.php on line 291.
With tcpdf, I don't get any PDF at all, the browser window displays
TCPDF error: Can't open image file: /my/site/public_html/system/files/Example640.png
and the log contains the errors:
getimagesize(/my/site/public_html/system/files/Example640.png) [<a href='function.getimagesize'>function.getimagesize</a>]: failed to open stream: No such file or directory in /my/site/drupal/modules/print/tcpdf/tcpdf.php on line 3847.
fopen(/my/site/public_html/system/files/Example640.png) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in /my/site/drupal/modules/print/tcpdf/tcpdf.php on line 4071.
(seems like tcpdf has problems with Drupal's "Private" download method? the image is actually in /my/site/private-files/Example640.png, i.e., outside the public_html root directory)
Any ideas? I'd prefer to get dompdf working, as the files generated by tcpdf are insanely huge (>1.5MB for a few lines of text)...
Comments
Comment #1
jcnventuraHi,
Support for the 'private' filesystem has been the subject of recent changes to the code. Can you try the latest dev to check whether the problem has already been fixed?
Thanks,
João
Comment #2
rene_w commentedI've tried the latest 6.x development snapshot (2008-Dec-16). What happens now is:
but there are still no images in the generated PDF (there's just blank space the approximate size of the image).
There are also a number of smaller usability issues with the generated PDF (perhaps these should go into a new comment?):
Comment #3
jcnventuraHi,
Thanks for your feedback. Regarding your issues:
1. If TCPDF is able to generate it correctly, but dompdf isn't, then the problem is in dompdf, and there's nothing I can do about it.
2. The small size of images in TCPDF is a known problem when the width and height attributes are not specified. You'll have to specify them to get images with better size. Maybe you can submit an issue in TCPDF's issue queue (see the website from where you downloaded it).
3. I will try to switch to pushbutton and try to see if I can identify a problem.
4. The size of TCPDF-generated files has been solved for some time now. If you go to 'admin/settings/print/pdf', read the description below 'Font Family' on how to solve it.
5. You can disable the URL list in the PDFs on each content type by going to to it's configuration form and disabling it there. A general output format setting might be useful, indeed.
6. Do you mean PDF-internal bookmarks? I don't know whether this is even possible. I will try to take a look at it.
Comment #4
rene_w commentedThanks for the quick response. To follow-up on some of the points:
This effects both the "Printer-friendly" and the "PDF" version. What I'd like is to keep the URL list for the "Printer-friendly" version, but not the PDF version (since it has hyperlinks)?
Comment #5
jcnventuraHi,
While I am still here:
1. The private filesystem method wasn't even working until recently (since these libraries will ask for the image directly, Drupal will deny it). The solution was to replace the private URL with a file://real_location_in_file_system URL. If dompdf can't handle such an URL there's really nothing that can be done about it from inside this module.
2. Like other problems, TCPDF doens't handle all the CSS/style options. It's the way it is, and we have to live with it or complain in the issue queue.. :)
3. The pushbutton logo is being correctly displayed (access themes/pushbutton/logo.png to know why :) ).
5. I am not talking about the general override of the URL list setting. I am talking that in each content type configuration (admin/content/types), you'll find an option to disable the URL list in the generated PDF.
6. Indeed, disabling all anchor links in PDF might be the best option.
Comment #6
rene_w commentedRe: #5: yep, got it. I know it's even in the documentation, but after staring at the module options page too long it really didn't occur to me to check the content type configuration. Perhaps a simple comment concerning the per-content type configuration (or even a link) under the Printer-friendly URLs list option on the settings page could help people like me who don't breathe "Printer-friendly" configuration all day ;) Something like "If set, a list of the destination URLs for the page links will be displayed at the bottom of the page. Note that you can enable/disable the URL list for each content type individually on the admin/content/types/list page.".
Comment #7
jcnventuraComment #8
splendidus commentedHi everybody!
I had also an “Invalid Expression” Problem. After several hours of searching and trying, I finally found ‘the’ solution in my case.
The key words are: character encoding, UTF-8, BOM.
I have my styles in a separate css-file, which I link to my php-file.
My editor added a BOM (http://unicode.org/faq/utf_bom.html#BOM) at the beginning of my css-file, while saving it using a UTF-8 encoding.
It was not visible in the editor, but the DOMPDF read it as a ‘’ directly prior to my first style element ‘body’, and ‘body’ is indeed an invalid expression.
Hope this helps somebody…
Comment #9
dampez commentedhi can anyone tell me how to display the node images in the pdf?
am using http://drupal.org/project/print
Cheers!
Comment #10
janmech commentedin my case dompdf does not display .png - jpeg works fine.
Comment #11
venkatadapa commentedUse the dompdf version 6 to fix all image and css issues. For me it is working like a charm.
http://code.google.com/p/dompdf/downloads/detail?name=dompdf_0-6-0_beta1...
In dompdf/dompdf/dompdf_config.inc.php file change error reporting to '0' otherwise you will see
some warnings in the webages those can't be fixed, And these are only warnings so that you can set
to zero to hide the warnings in production sites.
error_reporting('0');
Regards,
Venkat.
Comment #12
rene_w commentedThanks for the tip, I've tried out dompdf-6.0-beta1; it's good, but not good enough for my web site:
- images at the end of a page are simply cut off (they are inserted via the image_assist module)
- code is not printed correctly (blockregion module), all lines are overprinted on one like on an old line printer...
- simple lists (
<dl> <dt> <dd>) are not rendered correctlyFor now, I'm still using tcpdf (v5_9_034), but it doesn't look good, either:
- all images are "thumbnail-sized"
- blockregion code is rendered with insanely huge spacing
- font encoding problems ("?" for most non-ASCII-characters)
Can't believe it is almost 2011 and this is still so difficult :-(