Image not working in template from 1.6

I have a html img balise inside my template for my logo.
But since my last IP update from 1.5.x to 1.6, the image loaded by html are not working anymore inside the generated pdf :

On my template, I have this call :

<img src="<?php echo base_url(); ?>assets/default/img/logo-blanc.png" alt="" />

The URL https://mydomain.com/assets/default/img/logo-blanc.png is working well : I get my logo.

On the Apache2 log, I get this :

51.yyy.xxx.33 - - [19/Sep/2023:16:00:07 +0200] "GET /assets/default/css/spheerys.css HTTP/1.1" 200 3437 "-" "-"
51.yyy.xxx.33 - - [19/Sep/2023:16:00:07 +0200] "GET /assets/default/img/fond.jpg HTTP/1.1" 200 60751 "-" "-"
51.yyy.xxx.33 - - [19/Sep/2023:16:00:07 +0200] "GET /assets/default/img/logo-blanc.png HTTP/1.1" 200 11431 "-" "-"
88.zzz.ccc.133 - - [19/Sep/2023:16:00:07 +0200] "GET /quotes/generate_pdf/373 HTTP/1.0" 200 140829 "https://mydomain.com/quotes/view/373" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"

So it’s looking good !

What changed during upgrade ? mPDF version ?

Hi there,
Check out this PR: 898: Fix bug where logo wasn't found while creating PDF invoice by nielsdrost7 · Pull Request #964 · InvoicePlane/InvoicePlane · GitHub
It’s a change that’s also merged in the development branch and ready for beta and final releases
I don’t know what changed between versions, i just know that it’s a pain.
Luckily this PR resolved the problem

Thanks for your help UnderDog :slight_smile:

I had applied the PR but it doesn’t solved the problem.
The point is my html code doesn’t use the uploaded logo (from the settings), but just an image hosted on the server.
I tried this code instead my initial one (see first post) :

<img src="https://mydomain.com/assets/default/img/logo-blanc.png" alt="" />

But it doesn’t change the result on the generated pdf file : the logo doesn’t appear and I have the red cross instead.

And I don’t understand why… and how to solve the issue :frowning:

I had applied the PR but it doesn’t solved the problem.

Don’t forget there are 2 PR’s regarding this problem.

I don’t know if this will help, but:

  1. put an extra slash after that base_url()
    I see in your apache log, that it is getting that image, but you’ll never know

  2. make an extra function my_url() and use that in your template. From there you can use absolute_path and things like that.

Part of the solution (in my opinion) is not using base_url but an absolute path to the image on the server

I looked the both PR but I’m insisting : they both concern the system settings for the logo (inside a helper function), but in my case, I just want to insert it with absolute path on the php template’s file.
On my “Invoice template.php” file I have this html code :

    <div id="company">
        <!--img src="<?php echo base_url(); ?>assets/default/img/logo-blanc.png" alt="" /-->
        <img src="https://mydomain.fr/assets/default/img/logo-blanc.png" alt="" />test

And as result, I get this :

So I’m on the right place, my absolute path is OK (checked on the browser), but the picture is still absent.

Very strange behavior isn’t it ?

I’ve had this before on a non-Invoiceplane related project, but that was with the full url to the image.

I can’t even remember if the pdf generator was mpdf.

Back then i dumped the html, right before it was sent to the pdf generator and checked everything.

For now i don’t know a solution yet

Hi @Spheerys, are you maybe using an absolute path to load an asset that is on the same domain as InvoicePlane is? In this case you might want to check that your server can resolve your domain to localhost. To do so, you might try to ping your own domain from the server console. Ideally for assets on the server you should use a relative path, since mpdf generates the files server side.

1 Like

Hello @Spheerys,

Maybe I can give some general tips here on what I do to see the correct urls (or other difficulties) related to mpdf…
I simply take the piece of code with the problem from my template “pdf/InvoicePlane.php” file and put it in “public/InvoicePlane_Web.php”.
E.g.:

Then I use a “webdev tool” to look at the code to see what my browser makes of this.
image

Here are some more possibilities you can test:

  • If you have a local web server set up you can also try removing the “s” of http(s) from your absolute path.
    So <img src="http://mydomain.fr/assets/default/img/logo-blanc.png" alt="" />test.
  • If you use the function invoice_logo_pdf() test if invoice_logo() works in your template.
    In fact, the id “invoice_logo” in the invoice_logo_pdf() function should be id=“logo”.

Maybe this can help…

Thanks a lot for your both answers @VeRony and @naui95
Unfortunately, I give up (for now) and I replace my nice logo by simply text…
I don’t have enough time and courage to investigate furthermore for the moment :frowning: