PDF-Writer icon indicating copy to clipboard operation
PDF-Writer copied to clipboard

Including SVG graphics in PDF

Open nashwaan opened this issue 7 years ago • 3 comments

Is there a way to incorporate vector graphics like .svg file using hummus library (similar to the way to including jpeg or tiff images)?

nashwaan avatar Jul 18 '16 11:07 nashwaan

There should be such a way. jpeg and tiff embedding is supported as a high level method in hummus, but svg is not. however, it should be possible to either embed a PDF version of that SVG acquired by other means than hummus, or translate it directly (as is how the implementation of JPG and TIFF images does).

I looked a little bit and came up with some links that might prove useful to you:

generics:

  • http://stackoverflow.com/questions/3360641/how-to-insert-a-svg-file-in-a-pdf-document
  • http://stackoverflow.com/questions/5835795/generating-pdfs-from-svg-input?rq=1

This one here: https://github.com/ahwolf/jsPDF/blob/master/jspdf.plugin.svgToPdf.js

shows an interesting approach which translates the SVG to underlying library commands. This is possible with hummus as well, as hummus provides access to vector based graphic operators of PDF. You can focus on features that you think are more common in SVG files that you will receive and do something similar. if you choose this approach you will need to become a little familiar with PDF drawing operators. start with this link to learn about methods of adding such content to PDF: https://github.com/galkahana/PDF-Writer/wiki/Adding-Content-to-PDF-Pages

galkahana avatar Jul 19 '16 05:07 galkahana

Thanks for your feedback. The approaches and links you provided are useful. Need to investigate a bit more to decide which approach that will be faster to implement.

nashwaan avatar Jul 19 '16 07:07 nashwaan

Any improvement on this?

ghost avatar Jan 18 '18 06:01 ghost