0

I've an application that outputs an SVG file, with text and images. The text elements in the SVG file have custom fonts.

I need the PDF file to display these text elements exactly as on the SVG. I tried to do this with TCPDF. The SVG to PDF conversion succeeds, but when I try to convert the PDF to JPG or PNG, the text is not displayed. I'm converting the PDF to JPG with Imagick.

Does anyone know how to include the text in the JPG images?

halfer
  • 19,824
  • 17
  • 99
  • 186

3 Answers3

0

Try using Inkscape. It's an opensource SVG editor. You can save as PDF, Export as PNG, and the learning curve is moderate enough.

It doesn't support jpeg directly though.

0

You can indeed call Inkscape from PHP - I've done it, see here. Using that approach you can render SVG to all of the formats you require: PDF, PNG and JPG.

If you have the custom fonts installed on your server, then you can render using these fonts - just be aware that this may make you a publisher, and so you will need to ensure you have the license to render using these fonts (or your users do, depending on whose content it is).

Inkscape is rarely installed on web servers by default, so you'll have to use a server on which you have root access, such as a VPS, and install it yourself.

You should bear in mind that there is a security vulnerability in Inkscape that permits user-originated files to steal server files and cause the server to run out of memory (i.e. crash). That fix is now public but I am not sure if it has been released. So, if you are rendering SVG files that have been uploaded by users, untaint carefully.

Community
  • 1
  • 1
halfer
  • 19,824
  • 17
  • 99
  • 186
-2

you can try xml2pdf from alt-soft