Inserting SVG into PDF

anton.vodostoev picture anton.vodostoev · Oct 13, 2014 · Viewed 14.6k times · Source

I have been working with Adobe PDF library from Datalogics (C++ Interface) and I need to insert some charts into a PDF-document being generated. It works if my charts are in JPEG-format. I mean this API supports inserting such images. But it's not a suitable format because images have bad quality. So I need to use some vector format. The matter is that the application (based on java-TeeChart library from Steema) that generates charts for me seems to support only one vector format: SVG (at least only one I know about).

Are there any possibilities to insert SVG into PDF using APDFL API or maybe somebody happens to know another way to solve the problem?

Thanks in advance!

Answer

Vel Genov picture Vel Genov · Jan 30, 2015

Inserting an SVG into your PDF file might prove difficult and not produce the correct results. It might be easier for you if you converted the SVG to a raster format first and then insert the raster image into the PDF. Keeping the resolution high when converting to a raster format should help you eliminate any quality related issues. There are a couple of free and popular utilities that you can use to do the conversion.

You can try the following 3 step approach:

  • Export the content from TeeChart into SVG format
  • Use a third party utility (there are some examples in the list below) to convert the SVG image to a raster image
  • Insert the raster image into your PDF

SVG tools

libRS - C++ based library

batik - Java library

If you have a high quality raster image from step 2, and the image is inserted into the PDF with a low quality, please provide me with the relevant code, and I can try to give you a hand with it.