Print Image in PDF using Flying saucer.
HTML code:
<?xml version="1.0" encoding="utf-8" ?>
<html>
<p>
<img src="Smallcheck.jpg" width="20" height="21"/>
</p>
</html>
When I convert the HTML to PDF using Flying Saucer. The generated PDF is not printing the images.
var outputForPdfStream = new this.ByteArrayOutputStream();
// tidy the html
var domdoc = this.domDocument;
var iTidy = new this.tidy();
iTidy.setShowWarnings(false);
iTidy.setXmlTags(false);
iTidy.setInputEncoding("UTF-8");
iTidy.setOutputEncoding("UTF-8");
iTidy.setXHTML(true);//
iTidy.setMakeClean(true);
domdoc = iTidy.parseDOM(inputStream, outputForPdfStream);
// Convert the document to XHTML panel and then rendering it into a PDF
var xhtmlPanel = new this.XHTMLPanel();
xhtmlPanel.setDocument(domdoc);
var renderer = new this.iTextRenderer();
renderer.setDocument(xhtmlPanel.getDocument(), null);
renderer.layout();
renderer.createPDF(bos);
bos.flush();
inputStream.close();
this.debug("INPUT STREAM" + inputStream);
var byteArray = bos.toByteArray();
var encodedString = this.StringUtil.base64Encode(byteArray);
this.debug("Encoded String" + encodedString);
Do I need to use any specific package to print image in PDF. Please let me know if you have any questions.