galkahana / PDF-Writer

High performance library for creating, modiyfing and parsing PDF files in C++
http://www.pdfhummus.com
Apache License 2.0
890 stars 211 forks source link

Including SVG graphics in PDF #54

Open nashwaan opened 8 years ago

nashwaan commented 8 years ago

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

galkahana commented 8 years ago

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:

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

nashwaan commented 8 years ago

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.

ghost commented 6 years ago

Any improvement on this?