I have come across various examples of adding svg to PDF using iText and Apache Batik but, Batik uses Graphics2D which is not supported in Android. Please help me resolve this. How can I add svg image to PDF via iText in Android. If you know of any alternatives to svg or iText library for adding a vector to PDF considering limited java packages available in Android do let me know. Thanks in advance.
Asked
Active
Viewed 632 times
0
-
use [this link](http://stackoverflow.com/questions/6875807/convert-svg-to-pdf). – Mehran Zamani Apr 16 '17 at 04:32
-
@MehranZamani thelink you gave uses Batik. Batik cannot work on Android as Batik needs Java2D which is not available. Please read the comment for proof on this question on stackoverflow. Everybody online seems to quote it. That's why my question is how do I do this?http://stackoverflow.com/questions/7418937/how-to-integrate-batik-with-android-to-open-display-svg-files – Manasvini Ganesh Apr 16 '17 at 06:14
-
i think you should first convert svg to image and then try to convert it to pdf. other than that, i think it is pointless to convert svg to pdf because svg is made that it scales up/down to any size, if you change it to pdf, its size get fixed. so why not using a fixed image instead of svg? – Mehran Zamani Apr 16 '17 at 06:49
-
@MehranZamani You last comment is wrong. PDF is a vector format, just like SVG. It is perfectly sensible to convert between them. – Paul LeBeau Apr 16 '17 at 07:17
-
from [wikipedia](https://en.wikipedia.org/wiki/Portable_Document_Format): The Portable Document Format (commonly referred to as PDF) is a file format used to present documents in a manner independent of application software, hardware, and operating systems.[2] Each PDF file encapsulates a complete description of a **fixed-layout** flat document, including the text, fonts, graphics, and other information needed to display it. – Mehran Zamani Apr 16 '17 at 07:39
-
@PaulLeBeau is somewhat right. PDF can contain anything raster and vector components both. Eg. ever clicked on an image in PDF and observed a blue selection? That is raster embedded in PDF. But sometimes this does not happen. Eg. Texts (True Type Fonts - TTFs) It is because TTF is vector. Any other ideas ? I really need a solution..asap – Manasvini Ganesh Apr 16 '17 at 07:39
-
SVGs can can contain bitmap images also. I left that out so as not to complicate my comment. My point was that they are functionally equivalent formats. – Paul LeBeau Apr 16 '17 at 07:43
-
Does the PDF generation **have** to be done on the device? Can you send the data to a server and have the PDF generated there (with Batik)? – Paul LeBeau Apr 16 '17 at 07:44
-
@PaulLeBeau thanks. I tried, it worked! – Manasvini Ganesh Apr 16 '17 at 11:01