[Skip to main content](#vessel-content)

#   PDF invoice

##

- **[hpbdesignCEO](/forum/user/77330-hpbdesignceo "View hpbdesignCEO's Profile")**
- [![hpbdesignCEO's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/77330-hpbdesignceo "View hpbdesignCEO's Profile") Topic Author
- [ Offline](/forum/user/77330-hpbdesignceo)

Less More

- Posts: 8
- Thank you received: 1
-
-

5 months 2 weeks ago [\#372000](#372000) by [hpbdesignCEO](/forum/user/77330-hpbdesignceo "View hpbdesignCEO's Profile")  *[PDF invoice](/forum/32-content-creation/910539-pdf-invoice#372000 "-- HikaShop version -- : 6.4.1 -- Joomla version -- : 6.1 -- PHP version -- : 8.4 -- Browser(s) name and version -- : Edge Version 148.0.3967.70 -- Error-message(debug-mod must be tuned on) -- : No image in invoice.php / pdf  Hi team,  today I am trying to change the layout etc in invoice.pdf  But I cant get my image to show in the pdf.  Please can you let me know what I need to do?  I am using the invoice.php in: plugins/hikashop/attachinvoice/attachinvoice  My code:         Logo not found:      All I am getting is this colored square in the attached image file :(  Kind regards Hans Peter Betzler")* was created by *[hpbdesignCEO](/forum/user/77330-hpbdesignceo "View hpbdesignCEO's Profile")*

-- HikaShop version -- : 6.4.1
-- Joomla version -- : 6.1
-- PHP version -- : 8.4
-- Browser(s) name and version -- : Edge Version 148.0.3967.70
-- Error-message(debug-mod must be tuned on) -- : No image in invoice.php / pdf

Hi team,

today I am trying to change the layout etc in invoice.pdf

But I cant get my image to show in the pdf.

Please can you let me know what I need to do?

I am using the invoice.php in: plugins/hikashop/attachinvoice/attachinvoice

My code:
&lt;!-- STORE LOGO --&gt;
&lt;?php
$logoPath = JPATH_ROOT . '/images/xxx.jpg';
?&gt;
&lt;?php if (is_file($logoPath)) : ?&gt;
&lt;div style="text-align:left; margin-bottom:20px;"&gt;
&lt;img src="&lt;?php echo $logoPath; ?&gt;" style="width:300px; height:auto;" alt="Logo"&gt;
&lt;/div&gt;
&lt;?php else : ?&gt;
&lt;div style="color:red; font-size:10px;"&gt;
Logo not found: &lt;?php echo $logoPath; ?&gt;
&lt;/div&gt;
&lt;?php endif; ?&gt;
&lt;!-- EO STORE LOGO --&gt;

All I am getting is this colored square in the attached image file ![:(](/media/kunena/emoticons/22.png ":(")
[ ![Logo Error.jpg](/forum/attachment/63188) ](/forum/attachment/63188 "Logo Error.jpg")

Kind regards
Hans Peter Betzler

- [ ![Logo Error.jpg](/forum/attachment/63188) ](/forum/attachment/63188 "Logo Error.jpg") [ ](/forum/attachment/63188?download=1 "Logo Error.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTEwNTM5LXBkZi1pbnZvaWNlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[hpbdesignCEO](/forum/user/77330-hpbdesignceo "View hpbdesignCEO's Profile")**
- [![hpbdesignCEO's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/77330-hpbdesignceo "View hpbdesignCEO's Profile") Topic Author
- [ Offline](/forum/user/77330-hpbdesignceo)

Less More

- Posts: 8
- Thank you received: 1
-
-

5 months 2 weeks ago [\#372004](#372004) by [hpbdesignCEO](/forum/user/77330-hpbdesignceo "View hpbdesignCEO's Profile")  Replied by *[hpbdesignCEO](/forum/user/77330-hpbdesignceo "View hpbdesignCEO's Profile")* on topic *[PDF invoice](/forum/32-content-creation/910539-pdf-invoice#372004 "-- HikaShop version -- : 6.4.1 -- Joomla version -- : 6.1 -- PHP version -- : 8.4 -- Browser(s) name and version -- : Edge Version 148.0.3967.70 -- Error-message(debug-mod must be tuned on) -- : No image in invoice.php / pdf  Hi team,  today I am trying to change the layout etc in invoice.pdf  But I cant get my image to show in the pdf.  Please can you let me know what I need to do?  I am using the invoice.php in: plugins/hikashop/attachinvoice/attachinvoice  My code:         Logo not found:      All I am getting is this colored square in the attached image file :(  Kind regards Hans Peter Betzler")*

Hi team,
thanks to ChatGPT i got a code that works.

Would you like to tell me please is this code save to use?

&lt;!-- STORE LOGO --&gt;
&lt;?php
$logoPath = JPATH_ROOT . '/images/logo/logo.jpg';

if (is_file($logoPath)) {
$logoData = base64_encode(file_get_contents($logoPath));
$logoInfo = getimagesize($logoPath);

if ($logoInfo !== false) {
$mime = $logoInfo;
?&gt;
&lt;div style="text-align:left; margin-bottom:20px;"&gt;
&lt;img
src="data:&lt;?php echo $mime; ?&gt;;base64,&lt;?php echo $logoData; ?&gt;"
style="width:170px; height:auto;"
&gt;
&lt;/div&gt;
&lt;?php
}
}
?&gt;
&lt;!-- EO STORE LOGO --&gt;

Kind regards
Hans Peter Betzler

The following user(s) said Thank You: [easyconnect83](/forum/user/30833-easyconnect83 "View easyconnect83's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTEwNTM5LXBkZi1pbnZvaWNlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86324
- Thank you received: 14285
-
-

5 months 2 weeks ago [\#372005](#372005) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[PDF invoice](/forum/32-content-creation/910539-pdf-invoice#372005 "-- HikaShop version -- : 6.4.1 -- Joomla version -- : 6.1 -- PHP version -- : 8.4 -- Browser(s) name and version -- : Edge Version 148.0.3967.70 -- Error-message(debug-mod must be tuned on) -- : No image in invoice.php / pdf  Hi team,  today I am trying to change the layout etc in invoice.pdf  But I cant get my image to show in the pdf.  Please can you let me know what I need to do?  I am using the invoice.php in: plugins/hikashop/attachinvoice/attachinvoice  My code:         Logo not found:      All I am getting is this colored square in the attached image file :(  Kind regards Hans Peter Betzler")*

Hello,

Yes, base64 is safe. HTML2PDF has an explicit code path for "data:" image sources (it base64-decodes them internally before drawing), so this is a perfectly legitimate way around the file path issue.

For context on what you were seeing: the pinkish-gray square is the placeholder HTML2PDF draws when it cannot actually load an image. Our PDF plugin tries to make image loading reliable by detecting img src attributes that point at your site URL and rewriting them to the equivalent local filesystem path (so the library reads the file directly instead of going through HTTP). It also probes each image with getimagesize() and logs an "Image not accessible" warning to the HikaShop log when it fails. But that whole machinery only helps when the underlying file is actually readable by the PHP process; if it is not (file permissions, open_basedir restriction, or anything else that blocks the read) the placeholder is the final result. Base64 sidesteps all of that because the bytes travel inside the HTML itself, no file lookup is needed at PDF time, so it works in environments where direct path access does not.

One bug to fix in your snippet: "$mime = $logoInfo;" assigns the whole array returned by getimagesize instead of the MIME type, which produces "data:Array;base64,..." in the src attribute. You want the "mime" index:
Code:

$mime = $logoInfo['mime'];

The rest is fine.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vOTEwNTM5LXBkZi1pbnZvaWNlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.045 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
