PDF invoice plugin 4.1.3 — logo not rendered with the default invoice layout

  • Posts: 262
  • Thank you received: 9
5 days 22 hours ago #373311

Hello,

The store logo renders correctly with flat_invoice and corporate_invoice, but shows as a pink placeholder box with the default invoice layout.

Environment: HikaShop Business 6.5.2, PDF invoice plugin 4.1.3, Joomla 5.4.8, PHP 8.2.

The cause is the quoting of the src attribute. In invoice.php:

php
<img src="<?php echo $image_address_path; ?>" style="<?php echo $img_style; ?>">

flat_invoice.php and corporate_invoice.php use single quotes instead:

php
<img src='<?php echo $image_address_path; ?>' style='<?php echo $img_style; ?>'>

_preprocessImages() correctly replaces the URL with the local temp file path, but something afterwards — hikashop_absoluteURL() or the rendering — only handles the single-quoted form. With double quotes, the final HTML sent to html2pdf contains:

html
<img src=" www.lact.fr/home/lact/htdocs/lact.fr/tmp/hk_inv_img_kFPdBu.png " ...>

The site domain prepended to an absolute filesystem path. With single quotes, the same code produces the correct src='/home/lact/htdocs/lact.fr/tmp/hk_inv_img_lWUWzU.png' and the logo appears.

Switching to single quotes in our layout override fixed it. It looks like invoice.php just needs the same quoting as the other layouts.

Two side notes while testing:

The security hardening in spipu/html2pdf rejects any remote path because the allowed hosts list is never populated — we had to add $html2pdf->getSecurityService()->addAllowedHost(...) after the Html2Pdf instantiation to get past Unauthorized path host.

_preprocessImages() leaves the zero-byte stub created by tempnam() behind, since the shutdown function unlinks $tmp . '.png' rather than $tmp. Minor, but they accumulate.

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

  • Posts: 86114
  • Thank you received: 14210
  • MODERATOR
5 days 18 hours ago #373315

Hello,

Thank you for the report, and for the precise diagnosis. Your analysis was right, and it led us straight to the cause.

The quoting is the symptom rather than the cause. What actually happens is that _getPDFInvoice() calls hikashop_absoluteURL() a second time, on the content assembled after each invoice has already been through it and through _preprocessImages(). By that point the src holds the local temp file that _preprocessImages() wrote, and the second pass puts the site address in front of it. hikashop_absoluteURL() only rewrites double-quoted attributes, which is exactly why invoice.php was the only layout affected and why your single-quote override worked around it. We removed that second call rather than changing the quoting, so all four layouts print the logo without an override.

Your two side notes were both real, and are fixed as well:

The allowed hosts list of html2pdf is now filled with the addresses of the shop, so an image read from an address no longer stops the invoice with "Unauthorized path host". This one came in with html2pdf 5.3.3, which the plugin picked up in 4.0.9. On top of that, the plugin now also strips the folder Joomla is installed in when it maps an image address onto a file on the server, so the logo is found locally in more cases and the question does not come up at all.

tempnam() creates the file under the name it returns, so appending '.png' meant the stub was never the file being deleted. Both names are removed now, in _preprocessImages() and for the Factur-X XML.

We've published version 4.1.4 of the plugin with the fixes. We tested it here on the four bundled layouts, with a logo read from a file and with a logo read from an address, and the logo is in the PDF in all of them.

The following user(s) said Thank You: laurent

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

Time to create page: 0.053 seconds
Powered by Kunena Forum