Reputation: 3167
I am having an issue to parse an image within HTML structure to a PDF file, I have tried using the following line to gather the image , however the PDF file is being created without the image. I am using iText with xmlworker libraries, the html is all stored in a string then parsed into an input stream as shown below in code.
.....
<img class='top' src='file:///android_res/drawable/logo.png' height='100px' width='200px'/>
........
........
InputStream is = new ByteArrayInputStream(str.getBytes()); //contains the html string
XMLWorkerHelper.getInstance().parseXHtml(writer, document, is);
Upvotes: 1
Views: 1539
Reputation: 1577
You should probably use your own ImageProvider to fetch the images. (http://api.itextpdf.com/xml/com/itextpdf/tool/xml/pipeline/html/ImageProvider.html)
This interface has 4 methods:
You'll need to implement the retrieve method to return the Image from your file system.
Documentation on XMLWorker: http://demo.itextsupport.com/xmlworker/itextdoc/flatsite.html#itextdoc-menu-10
Upvotes: 2