Cannot include images into invoice

  • Posts: 27
  • Thank you received: 1
8 years 9 months ago #229544

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.4.8
-- PHP version -- : 5.3.10
-- Browser(s) name and version -- : Safari 6.2.8
-- Error-message(debug-mod must be tuned on) -- : ×
ERROR n°6
File : /var/www/clients/client65/web100/web/plugins/hikashop/attachinvoice/attachinvoice/html2pdf.class.php
Line : 1326

Impossible to load the image www.meintraining.at/images/logo.gif

I edited the file /hikashop/attachinvoice/attachinvoice/invoice.php to customize the invoice layout.
All works fine, except when I try to include the logo image to the invoice.

Tried several ways:

<img src="/var/www/clients/client65/web100/web/images/logo.gif"/>
<img src=" www.meintraining.at/images/logo.gif"/ >
and with format .png but keep getting above error.

I read through several forum entries and checked php setting

allow_url_fopen On

There must be a problem with tcpdf opening an image file, but don't know how to debug or solve.
Pls advice on how to include logo image to the invoice.


There are no kangaroos in Austria! ;-)

Please Log in or Create an account to join the conversation.

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
8 years 9 months ago #229573

hello,

Just a check :
- Did you change your php.ini ?
=> You must turned "ON" the "allow_url_fopen" if you use URL to add an image.

Maybe if you have already done this, that will be more easy to have a look on your code, and to process some tests.
Hope this will help, keep in touch.

Regards,

Last edit: 8 years 9 months ago by Philip.

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 1
8 years 9 months ago #229784

Hello,

it is turned on. I checked again with phpinfo (see image)


allow_url_fopen On

the code where the image is included is just like this:

<table class="header">
<tr>
<td colspan="1"><img src=" www.meintraining.at/images/logo.gif"/ >
</td>
<td colspan="5">
<div class="storeaddress">
<?php
$store = str_replace(array("\r\n","\n","\r"),array('<br/>','<br/>','<br/>'),$config->get('store_address',''));
if(JText::_($store)!=$store){
$store = JText::_($store);
}
echo $store;
?>
</div>
</td>
</tr>
</table>

What else can I test, has this worked ever in an invoice?


There are no kangaroos in Austria! ;-)
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 9 months ago #229792

Hi,

Yes, it works on most servers. But it seems that on some servers the tcpdf we use to conver the HTML of the invoice into a PDF is not able to get the images because of the way the server is configured.

Can you confirm with your hosting company that your server is able to send requests to third party servers ? Sometimes hosting companies block that to prevent abuses of their servers for spam.

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 1
8 years 9 months ago #230954

Hello,

I'm not sure what to check with the hosting provider precisely..

The allow_url_fopen=on (according to phpinfo)
I even tried to install the latest tcpdf version (6.2.12) and use this, but also not working.

Any more hint what I could check ? Why is there a request to third party server anyway? Can't the image be loaded locally?


There are no kangaroos in Austria! ;-)

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 8 months ago #231033

Hi,

If you enter a URL for the image, the plugin has to load the image through a request to the domain name of that URL. So it requires connection to the outside (even though it goes back on the same server).
If you enter a local path of the image it should be able to load it directly from the folder without that.
So you can try that.

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 1
8 years 8 months ago #231213

Hello
I tried with a local image path, like this:

img src="/web/plugins/hikashop/attachinvoice/attachinvoice/_tcpdf_5.0.002/images/logo.png"
->
File : /var/www/clients/client65/web100/web/plugins/hikashop/attachinvoice/attachinvoice/html2pdf.class.php
Line : 1328
Impossible to load the image meintraining.at/web/plugins/hikashop/att....002/images/logo.png

OR
<td colspan="1"><img src="logo.png"/>
->
File : /var/www/clients/client65/web100/web/plugins/hikashop/attachinvoice/attachinvoice/html2pdf.class.php
Line : 1328
Impossible to load the image meintraining.at/logo.png

It seems it's converted to a http ref in any case!
How to load a local image here ?

I'm not so good at php but from tcpdf.php I read that the domain is added to image URL in every case?!

$imglink = '';
if (isset($this->HREF) AND !$this->empty_string($this->HREF)) {
$imglink = $this->HREF;
if ($imglink{0} == '#') {
// convert url to internal link
$page = intval(substr($imglink, 1));
$imglink = $this->AddLink();
$this->SetLink($imglink, 0, $page);
}
}


Any more hints what I could try? Thank you.


There are no kangaroos in Austria! ;-)

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 8 months ago #231220

Hi,

Well, I don't have any other idea.
Normally, the image tags work automatically with the PDF invoice system without doing anything. So I can't think of anything else than something on the server which prevents the tcpdf library to load the image.

Please Log in or Create an account to join the conversation.

  • Posts: 62
  • Thank you received: 1
8 years 7 months ago #236512

Carniel, did you try to use the full URL? Make sure you use a full url like:
domain.tld/images/logo.png instead of logo.png or /images/logo.png (http:// or https:// depending if your shop has a SSL certificate)

That did the trick for me.

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 0
7 years 11 months ago #256308

I have the same problem. Is there enyone who has solved this problem.??

Please Log in or Create an account to join the conversation.

  • Posts: 62
  • Thank you received: 1
7 years 11 months ago #256311

I solved it by using full URL's in the template instead of relative URL's.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 11 months ago #256310

Hi,

Well, the issue is that basically, that error says that the image can't be retrieved and included in the PDF.
So either the path you entered is wrong (because it's not the good folder, it's relative to the wrong folder, etc), or the image format is invalid, or the PHP cannot download files or doesn't have access to the folder where the image is stored, etc.
So there are many ways to solve the problem and each person having that problem will likely have it because of a different reason.

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 0
7 years 11 months ago #256423

All the things above I have checked. allow_url_fopen = on. directory I have tryed everything also with http://, https://, /var..... etc.
But is it possible that the used html2pdf in version 4.0.3, is to old to work with php7. The new version with adaptions to php 7 is html2pdf 4.5.1?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 11 months ago #256431

Hi,

If it would be too old to work with PHP7, then you wouldn't be able to get PDF files at all for your invoices.
The changelog for HTML2PDF is here: raw.githubusercontent.com/spipu/html2pdf/master/_changelog.txt
And it doesn't mention anything regarding PHP7 support since the 4.0.3 or anything regarding improvments on images support.
So if you have a problem with image display, all I can think of is a server restriction of some sort.

The following user(s) said Thank You: CarlosC

Please Log in or Create an account to join the conversation.

Time to create page: 0.113 seconds
Powered by Kunena Forum