I am on Drupal 6.8, I have tried both modules of print (6.x-1.0 and 6.x-1.x-dev). Dompdf works fine but it does not render images in the generated PDF. I found TCPDF has just come out with a PHP5 version.
My web server is Apacahe 2.2 hosted on FreeBSD 7.0.
To use the multi-site feature of Drupal I have placed Drupal as a virtual host.
My server document root is at /usr/local/www/apache22/data
And the drupal directory is placed at the server document root.
A couple of Virtual hosts such as site1.example.com and site2.example.com are created which refer to /usr/local/www/apache22/data/drupal6. [Drupal is excellent in resolving that].
The INSTALL.txt of the print module suggests that the tcpdf directory should be placed in the print module directory itself. But the tcpdf installation documentation suggests that it be placed at the web server document root.
When I place tcpdf directory in the server document root, it works perfectly, I can click on the example .php files and they are rendered perfectly in PDF but in this case the print module can't find a PDF generation tool. [because it expects that it would be in the same directory and not elsewhere].
And when I place the tcpdf directory in the print module's directory, it fails to generate a PDF. The first message it throws is this:
TCPDF error: Can't open image file: http://site1.example.com/themes/garland/logo.png
on clicking the back button of the browser I find a set of warning messages:
warning: getimagesize() [function.getimagesize]: php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /usr/local/www/apache22/data/drupal6/sites/all/modules/print/print_pdf/print_pdf.pages.inc on line 272.
warning: getimagesize(http://site1.example.com/themes/garland/logo.png) [function.getimagesize]: failed to open stream: php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /usr/local/www/apache22/data/drupal6/sites/all/modules/print/print_pdf/print_pdf.pages.inc on line 272.
warning: getimagesize() [function.getimagesize]: php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /usr/local/www/apache22/data/drupal6/sites/all/modules/print/tcpdf/tcpdf.php on line 3847.
warning: getimagesize(http://site1.example.com/themes/garland/logo.png) [function.getimagesize]: failed to open stream: php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /usr/local/www/apache22/data/drupal6/sites/all/modules/print/tcpdf/tcpdf.php on line 3847.
warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /usr/local/www/apache22/data/drupal6/sites/all/modules/print/tcpdf/tcpdf.php on line 4071.
warning: fopen(http://site1.example.com/themes/garland/logo.png) [function.fopen]: failed to open stream: php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /usr/local/www/apache22/data/drupal6/sites/all/modules/print/tcpdf/tcpdf.php on line 4071.
Looking at the messages I get a feeling that tcpdf is not able to resolve the server document root and the relative paths etc. [as is mentioned in the INSTALL.txt of the print module] this might be because of the virtual host situation.
There is a config file tcpdf_config.php which might be able to overcome this but I don't know what the values should be and how those variables need to be populated etc.
Many thanks in advance
Sanjay
Comments
Comment #1
jcnventuraHi,
In principle, you could have TCPDF installed in document root AND accessible inside the print module folder (just create a softlink using ln -s).
In the end, though it wouldn't matter much, as the module auto-configures TCPDF (correctly, I believe). That means that the contents of tcpdf_config.php are ignored, so don't bother with those.
From the error messages, it seems that your server doesn't know how to access itself (i.e. the PHP script can't access http://site1.example.com/themes/garland/logo.png). Maybe it's a case of permissions?
João
PS: TCPDF has had a PHP5 version for a long, long time.
Comment #2
sk_mamp_nb commentedThanks for that, I'll have a look at the permissions.
Comment #3
sk_mamp_nb commentedOn second thoughts...it well might be a case of permissions but I think it is not getting tested at the moment.
To me the problem seems to be one of resolving the path rather than accessing it.
The location of the logo file is at:
'/usr/local/www/apache22/data/drupal6/themes/garland/logo.png'
The server document root is at:
'/usr/local/www/apache22/data'
So I think when tcpdf complains about not being able to open the file 'http://site1.example.com/themes/garland/logo.png' it is because it looking at
'/usr/local/www/apache22/data/themes/garland/logo.png'
whereas it should be looking at
'/usr/local/www/apache22/data/drupal6/themes/garland/logo.png'.
The site at drupal6 appears as the server document root because it is on a virtual host.
But I am not sure that this is the case and I will work on the permissions aspect as well.
Thanks
Sanjay
Comment #4
jcnventuraI can't be sure, but if it says it is looking for a file in http://site1.example.com/themes/garland/logo.png, it means exactly that.. It is trying to fetch an image from that URL and not from the path you mentioned.
There have been reports of similar errors in the past (cases that escaped my testing) where it was indeed looking in a path, and the path was part of the error message.
João
Comment #5
sk_mamp_nb commentedI have given a full 777 to the themes and garland directories.
Also added explicit permissions in httpd.conf for both of these directories (drupal6 already had those permissions) allowing from all.
The httpd-error.log contains no message of any denials or forbidden directory access etc.
In my web browser I am able to look at each of the directories in the path and when I put the URL http://site1.example.com/themes/garland/logo.png in the address bar I am able to see the drupal logo.
So I am not sure what else could I open up for tcpdf to have access to the desired URL.
Comment #6
jcnventuraFrom the error messages, it seems that your server doesn't know it's own name.
Are you able to access that path from a process running on the server itself?
Comment #7
sk_mamp_nb commentedHow do I test that? There are not many processes running on this server apart from the webserver.
The VirtualHosts definitely are aware of their ServerName otherwise I would not have been able to access two different sites such as site1.example.com and site2.example.com and also a generic non-drupal test.example.com at the document root.
Moreover there are scores of other modules on /sites/all/modules which are accessible by the underlying sites correctly, so I am finding it a bit hard to take that the server doesn't know its own name but that is also a possibility.
What triggers the following message?
warning: getimagesize() [function.getimagesize]: php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /usr/local/www/apache22/data/drupal6/sites/default/modules/print/print_pdf/print_pdf.pages.inc on line 272
I guess it is looking for a hostname and a server name but where is it looking for this information?
I have also tried to play with the Stylesheet URL in the Settings giving it relative absolute paths but it makes no difference to the error messages.
Much appreciate your help.
Sanjay
Comment #8
sk_mamp_nb commentedOK, there's more...
I switched off the logos and icons on the theme. This produced a PDF the graphic rendering was passable but then there was magic...as if the document were written in invisible ink, as I scrolled up and down the page all the text and graphics were gone! Completely disappeared!
I tried the other two options of opening in a new browser window which resulted in a similar invisible ink experience and saving it as a local file produced a blank file.
How does this happen? I am really intrigued by this.
Well, I think it might be something to do with Adobe plugins? The reason I suspect it is this because I tried to create the PDF with all the three browsers at my disposal (Safari, Opera and Firefox) and luckily Firefox didn't have the plugin to open the PDF directly so it was opened with Preview (the default viewer on macs), I saved it. Preview opens it correctly without reporting any errors but Adobe Reader complains that there are errors and does the vanishing trick, showing the document for a few seconds and then presenting a blank screen.
So I have two problems: a) Inaccessible logos and icons and b) A PDF that contains errors
Thanks
Sanjay
Comment #9
gavri commentedi have the same problem with the logo - i have the site on a development server and all works fine but when ported to production i get this error of not finding the logo - one thing is that the base path in the production isn't "/" but "/corp"
Comment #10
jcnventuraDo you have images in your footer? If so, can you use the module's settings to change the footer used to a simple text string?
Other than the above question, I simply can't help you anymore without looking at the page causing the problems. Please send me the URL to your site and I will try to see what the problem is.
João
Comment #11
jcnventuraNo further info in two weeks. Closing the issue.
João