Search code examples
phppdfsvgpdflib

PDFlib create svg graphic from other image


Is it possible in PDFlib to create an svg graphic from another image-file (like png) and than put it out in the pdf? Like first load the png image with $p->load_graphics and than create a svg file within pdflib? I googled this but found nothing that fits my requirement.

For explanation: I have a png graphic and want to create a svg file within my pdflib program, so I can give this image a shadow. Or is it possible to put a shadow on the image through another way?


Solution

  • You can only create PDF output with PDFlib. If you want to manipulate your SVG in advance you must do so before using load_graphics(). (this is not a functionality of PDFlib)

    Please note, however, that PDFlib does not support all possible SVG filters. Especially feBlend and feGaussianBlur, which are commonly used for blur shadows, are not supported. (Please refer to chapter 8.2.8 "Unsupported SVG Features" in your or the current PDFlib tutorial for details.)

    Therefore, the more sensible variant is probably to apply an appropriate shadow to the PNG image in advance by image manipulation (eg. by using ImageMagick) and load the final PNG to PDFlib.