SIMITGROUP / phpjasperxml

This is a php wysiwyg report library
BSD 3-Clause "New" or "Revised" License
44 stars 45 forks source link

Image from database store as blob not able to display #83

Closed lvsan closed 2 years ago

lvsan commented 2 years ago

Hi,

I have try to display the image that is save under db with blob field type.

but the pdf never display the image. I debug the code, there is value have been display.

attachment is the value that is show when I console.

img.txt

the above never use the base_decode function yet.

Able to advise does the value return is correct? However, I have using path to display too, but nothing to be show too.

thanks..

kstan79 commented 2 years ago

blob is not supported directly, you may refer https://github.com/SIMITGROUP/phpjasperxml/blob/master/src/PHPJasperXML_elements.php line 126

there is 2 alternative:

  1. try change your expression from $F{image} to base64_encode($F{image}), hope it working
  2. add blob process in the code and send pull request.

By the way, it is bad to keep images content in database, please stop this method. It increase your database management overhead, and hard to scale.

lvsan commented 2 years ago

Hi kstan,

Thanks. I know for that, currently will stop using the image contents. but now i am still facing the issues to display when i change it using path or filename.

attachment is the jrxml that i using for the reports.

img.txt

Does i need to identify the class for the image?

Possible advise me cause most of my customer will display the image for their invoice.

thanks.

lvsan commented 2 years ago

hi,

below is the imageExpression that i have:

array(8) { ["x"]=> string(1) "4" ["y"]=> string(1) "8" ["width"]=> string(2) "69" ["height"]=> string(2) "60" ["uuid"]=> string(36) "6e3e8e21-7c40-4064-96b9-41570f74704e" ["elementtype"]=> string(5) "image" ["imageExpression"]=> string(59) "D:\wamp64\www\xxxxxx\reports\companylogo.png" ["band"]=> string(8) "detail_0" }

kstan79 commented 2 years ago

it seems like bugs, you try check https://github.com/SIMITGROUP/phpjasperxml/blob/master/src/Exports/Pdf_driver.php line 268-277.

You try put in your $imagetype accordingly see it work? Pdf_driver extend from TCPDF class, the $this->drawtarget->Image() actually from upstream.

I saw it $imagetype='' but i cant recall the reason.

Upstream you can refer: https://tcpdf.org/examples/example_009/

lvsan commented 2 years ago

Hi,

I have try but still the same. finally i able to display if i upload the image that is under jpeg format, png is not supported. Will check while does the png format is not supported. -- seem like not all the png file is supported, i change another png image file, and it is working fine.

Thanks.

lvsan commented 2 years ago

I found the image have error as below: GD library error: imagecreatefrompng(): gd-png: libpng warning: iCCP: known incorrect sRGB profile

therefore cannot load. I will check what can I do for this error.

Thanks.

lvsan commented 2 years ago

Hi,

I manage to solve the issues and able to viewing the image now. To solve this , i need to download the latest version for TCPDF V6.4.4 from https://github.com/tecnickcom/TCPDF

and then, under the filename "tcpdf.php" , amend the $img = imagecreatefrompng($file); ==> $img = @imagecreatefrompng($file);

Thanks.

kstan79 commented 2 years ago

Then you may fill report to tcpdf team for this fix. Cause nobody wish to change code which is manage by composer

lvsan commented 2 years ago

GD library error: imagecreatefrompng(): gd-png: libpng warning: iCCP: known incorrect sRGB profile

Yes. I have report this to the tcpdf team. thanks.