Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After updating IP to v1.6.0 and PHP to 8.1 invoices/generate_pdf no longer works (with SVG?) #898

Closed
5 tasks done
ctsde-markus opened this issue Dec 8, 2022 · 9 comments · Fixed by #897 or #964
Closed
5 tasks done
Assignees
Milestone

Comments

@ctsde-markus
Copy link
Contributor

Expected Behavior

Generate a PDF of an invoice.

Current Behavior

I get errors stating that it could not find an image file:

An uncaught Exception was encountered

Type: Mpdf\MpdfImageException

Message: Could not find image file (file:///usr/local/www/invoiceplane/app-v1.6.0/uploads/CTS_Logo_Vector.svg)

Filename: /usr/local/www/invoiceplane/app-v1.6.0/vendor/mpdf/mpdf/src/Image/ImageProcessor.php

Line Number: 589

Backtrace:

File: /usr/local/www/invoiceplane/app-v1.6.0/vendor/mpdf/mpdf/src/Image/ImageProcessor.php
Line: 211
Function: imageError

File: /usr/local/www/invoiceplane/app-v1.6.0/vendor/mpdf/mpdf/src/Tag/Img.php
Line: 276
Function: getImage

File: /usr/local/www/invoiceplane/app-v1.6.0/vendor/mpdf/mpdf/src/Tag.php
Line: 240
Function: open

File: /usr/local/www/invoiceplane/app-v1.6.0/vendor/mpdf/mpdf/src/Mpdf.php
Line: 13875
Function: OpenTag

File: /usr/local/www/invoiceplane/app-v1.6.0/application/helpers/mpdf_helper.php
Line: 96
Function: WriteHTML

File: /usr/local/www/invoiceplane/app-v1.6.0/application/helpers/pdf_helper.php
Line: 105
Function: pdf_create

File: /usr/local/www/invoiceplane/app-v1.6.0/application/modules/invoices/controllers/Invoices.php
Line: 272
Function: generate_invoice_pdf

File: /usr/local/www/invoiceplane/app-v1.6.0/index.php
Line: 329
Function: require_once

The file itself is there and the user running the php-fpm process can read it, in fact it even owns the file:

invplane> ls -l /usr/local/www/invoiceplane/app-v1.6.0/uploads/CTS_Logo_Vector.svg
-rw-r--r--  1 invplane  invplane  337897 Jul 22  2020 /usr/local/www/invoiceplane/app-v1.6.0/uploads/CTS_Logo_Vector.svg

I can still download already created .pdf Files from .../uploads/archive/ so there can't be any permission problem down the path.

I checked with phpinfo() that all required modules for mpdf are enabled:

  • mbstring
  • gd
  • zlib
  • bcmath
  • xml

Steps to Reproduce

Update my installation vom 1.5.11 to 1.6.0 and upgrade from PHP-7.4 to PHP-8.1.13 on FreeBSD. The previous version worked fine with PHP-7.4.

Failure Logs

I only see a 500 error in the nginx-vhost-access.log. No further error messages than those mentioned above. It seems that it no longer can interpret the .SVG file in mpdf with PHP-8.1.

@nielsdrost7
Copy link
Contributor

nielsdrost7 commented Dec 8, 2022

@ctsde-markus thank you for the bug report.

We just had a pull-request resolving this issue:
https://github.com/InvoicePlane/InvoicePlane/pull/897/files
It's already merged into the development branch.

Would you mind quickly changing that file, so it resolves your issue

@nielsdrost7 nielsdrost7 reopened this Dec 8, 2022
@naui95 naui95 added this to the 1.6.1 milestone Dec 9, 2022
@ctsde-markus
Copy link
Contributor Author

@ctsde-markus thank you for the bug report.

We just had a pull-request resolving this issue: https://github.com/InvoicePlane/InvoicePlane/pull/897/files It's already merged into the development branch.

Would you mind quickly changing that file, so it resolves your issue

This solves the problem for me! Thank you very much!

Bye
Markus

@naui95 naui95 linked a pull request Dec 10, 2022 that will close this issue
7 tasks
@naui95
Copy link
Contributor

naui95 commented Dec 10, 2022

Closing issue. Fixed by MR #897

@naui95 naui95 closed this as completed Dec 10, 2022
@reproteq
Copy link

reproteq commented Jun 25, 2023

i have same issue and solved with this

if ($CI->mdl_settings->setting('invoice_logo')) {

.................

$absolutePath = dirname(dirname(__DIR__));
return '<img src="' . $absolutePath . '/uploads/' . $CI->mdl_settings->setting('invoice_logo') . '">';

@nielsdrost7
Copy link
Contributor

@reproteq does that mean that the solution in https://github.com/InvoicePlane/InvoicePlane/pull/897/files didn't work for you and you had to make extra adjustments with that absolute path?

@reproteq
Copy link

exactly that

@nielsdrost7
Copy link
Contributor

Reopened: In some cases the logo still doesn't show. Above solution helps solve that.

Requires a PR for the development branch, so we can add it to the new upcoming beta version

@nielsdrost7
Copy link
Contributor

Let's see if this code is in Beta, otherwise change it.
Also see comments on the closed pull-request regarding the PDF Logo

On line 22 to 25:

if ($CI->mdl_settings->setting('invoice_logo')) {
        $absolutePath = dirname(dirname(__DIR__));
		return '<img src="' . $absolutePath . '/uploads/' . $CI->mdl_settings->setting('invoice_logo') . '">';
    }

On line 39 to 42:

if ($CI->mdl_settings->setting('invoice_logo')) {
		$absolutePath = dirname(dirname(__DIR__));
		return '<img src="' . $absolutePath . '/uploads/' . $CI->mdl_settings->setting('invoice_logo') . '" id="invoice-logo">';
    }

@nielsdrost7
Copy link
Contributor

@reproteq I fixed the bug, checkout the PR: https://github.com/InvoicePlane/InvoicePlane/pull/964/files
Solution will be merged in new version, coming up soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment