tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.18k stars 1.51k forks source link

SVG detection fix for inline data images #646

Open THenkeDE opened 1 year ago

THenkeDE commented 1 year ago

Fixes: #645

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

williamdes commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 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 commented 11 months ago

any updates? did i miss something?

williamdes commented 11 months ago

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 commented 7 months ago

@nicolaasuni what do you think about this fix ?

nicolaasuni commented 5 months ago

Please try to resolve the conflicts.