TCPDF icon indicating copy to clipboard operation
TCPDF copied to clipboard

SVG detection fix for inline data images

Open THenkeDE opened this issue 1 year ago • 9 comments

Fixes: #645

THenkeDE avatar Sep 11 '23 08:09 THenkeDE

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 11 '23 08:09 CLAassistant

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?

williamdes avatar Sep 11 '23 08:09 williamdes

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"

THenkeDE avatar Sep 11 '23 09:09 THenkeDE

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 ?

williamdes avatar Sep 11 '23 09:09 williamdes

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 avatar Sep 11 '23 14:09 THenkeDE

any updates? did i miss something?

THenkeDE avatar Oct 17 '23 09:10 THenkeDE

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 avatar Oct 17 '23 10:10 williamdes

@nicolaasuni what do you think about this fix ?

williamdes avatar Feb 22 '24 22:02 williamdes

Please try to resolve the conflicts.

nicolaasuni avatar Apr 20 '24 17:04 nicolaasuni