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

SVG detection fix for inline data images #646

Closed
wants to merge 31 commits into from

Conversation

THenkeDE
Copy link

@THenkeDE THenkeDE commented Sep 11, 2023

Fixes: #645

remicollet and others added 23 commits September 6, 2023 08:51
…#620)

Tested and confirmed working in PHP 7.4 and PHP 8.2
* README: tone down the warning about tc-lib-pdf

Signed-off-by: Ruben Barkow-Kuder <[email protected]>

* Update README.md

Co-authored-by: William Desportes <[email protected]>

---------

Signed-off-by: Ruben Barkow-Kuder <[email protected]>
Co-authored-by: William Desportes <[email protected]>
* Fix of Deprecation warning with php 8.1 tecnickcom#614

* Update include/barcodes/qrcode.php

Co-authored-by: William Desportes <[email protected]>

---------

Co-authored-by: Robert Johnson Nallori <[email protected]>
Co-authored-by: johnson361 <[email protected]>
Co-authored-by: William Desportes <[email protected]>
…om#633)

* Update tcpdf_fonts.php

Fixes "use of "self" in callables is deprecated" warning is arising from tcpdf_fonts.php when using PHP >= 8.2

* Update tcpdf_fonts.php for PHP 5.3-8.2 compatibility

PHP 8.2 "use of "self" in callables is deprecated" yet some ways of fixing this breaks for PHP 5.3. This approach works, tested PHP 5.3.29 - 8.2.0

* Update tcpdf_fonts.php

Spaces added back in before arguments

* Update tcpdf_fonts.php using get_called_class()

Maneuvers compatibility of callables inside array_map() between PHP 5.3 and 8.2 - tested.

---------

Co-authored-by: Nicola Asuni <[email protected]>
* Fix composite glyph output

* Pad zeros before checksum calulation

---------

Co-authored-by: Nicola Asuni <[email protected]>
* fix for tecnickcom#583

* fix fix

---------

Co-authored-by: Nicola Asuni <[email protected]>
* Fix non-numeric value warning

Fixes this warning on generating PDF:
Warning: A non-numeric value encountered in /tcpdf/tcpdf.php on line 5473

* Better fix for non-numeric value warning

Fixes this warning on generating PDF after calling `Text` with a non-numeric value for `$fstroke`:
Warning: A non-numeric value encountered in /tcpdf/tcpdf.php on line 5470

* Update tcpdf.php

Co-authored-by: William Desportes <[email protected]>

---------

Co-authored-by: William Desportes <[email protected]>
Co-authored-by: Nicola Asuni <[email protected]>
This was already fixed in tc-lib-barcode.
* Fix return type annotation

* BC with tools that do not support PHPStan annotations

Co-authored-by: William Desportes <[email protected]>

---------

Co-authored-by: William Desportes <[email protected]>
Co-authored-by: Nicola Asuni <[email protected]>
tecnickcom#598)

* Typehints for get/setHeaderMargin are inconstent

* Add typehints for header/footer margin properties

---------

Co-authored-by: Nicola Asuni <[email protected]>
* Bump actions/checkout and add PHP 8.3

* Update the composer json tests

* Remove PHP 5.3 and 5.4 from the matrix

* add permission entry

Restrict GitHub actions access

---------

Co-authored-by: Nicola Asuni <[email protected]>
@CLAassistant
Copy link

CLAassistant commented Sep 11, 2023

CLA assistant check
All committers have signed the CLA.

@williamdes
Copy link
Contributor

Thank you!
It's important to sign the CLA
Can you add an example in examples/ folder that illustrates what you fix with this fix?

@THenkeDE
Copy link
Author

i signed the CLA but i have no idea about any examples to add - it just fixes the detection of the image Filetype from "nothing" to "svg"

@williamdes
Copy link
Contributor

i signed the CLA but i have no idea about any examples to add

Thanks
Can you add Fixes: #645 to your PR description ?

it just fixes the detection of the image Filetype from "nothing" to "svg"

Yeah okay, how can I test it and see how you fix fixes something ?

@THenkeDE
Copy link
Author

If for example you have SVG files laying around and want to add the SVG to the HTML Code using

$svgString = file_get_contents('yourdesired.svg');

or alternatively the <svg...> data is coming from a database, you can prepare and add it to the html string like this:

$html = '<img src="@' . base64_encode($svgString) . ' width="13mm" height="13mm">';

Later on you add the html to the PDF using e.g. ->writeHTML.

Without my fix the following ( Font Awesome Arrow-Down Icon) will be broken because it is not detected as SVG Image:

<img src="@PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzODQgNTEyIiB3aWR0aD0iNG1tIiBoZWlnaHQ9IjRtbSI+PHBhdGggZD0iTTM3NC42IDMxMC42bC0xNjAgMTYwQzIwOC40IDQ3Ni45IDIwMC4yIDQ4MCAxOTIgNDgwcy0xNi4zOC0zLjEyNS0yMi42Mi05LjM3NWwtMTYwLTE2MGMtMTIuNS0xMi41LTEyLjUtMzIuNzUgMC00NS4yNXMzMi43NS0xMi41IDQ1LjI1IDBMMTYwIDM3MC44VjY0YzAtMTcuNjkgMTQuMzMtMzEuMSAzMS4xLTMxLjFTMjI0IDQ2LjMxIDIyNCA2NHYzMDYuOGwxMDUuNC0xMDUuNGMxMi41LTEyLjUgMzIuNzUtMTIuNSA0NS4yNSAwUzM4Ny4xIDI5OC4xIDM3NC42IDMxMC42eiIgZmlsbD0iIzAwM2Y3MCI+PC9wYXRoPjwvc3ZnPg==" width="13mm" height="13mm">

@THenkeDE
Copy link
Author

any updates? did i miss something?

@williamdes
Copy link
Contributor

any updates? did i miss something?

Still on my todo list, this is not my project
I only give some help to ensure this project continues to live
So I need to test your work at some point

If you can write an example file in examples/ folder
For example use example 66 (composer) as a base example.
That would definitely help

@williamdes
Copy link
Contributor

@nicolaasuni what do you think about this fix ?

@nicolaasuni
Copy link
Member

Please try to resolve the conflicts.

nicolaasuni added a commit that referenced this pull request Oct 26, 2024
* Ayesh: [PHP 8.4] Fix: Curl CURLOPT_BINARYTRANSFER deprecated #675

* THenkeDE: SVG detection fix for inline data images #646

* bruno-farias:  Fix count svg #647
@nicolaasuni
Copy link
Member

Thank you.
Manually merged at: #756

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SVG Filetype detection