0
使用飛碟在PDF中打印圖像。使用飛碟在PDF中打印圖像
HTML代碼:
<?xml version="1.0" encoding="utf-8" ?>
<html>
<p>
<img src="Smallcheck.jpg" width="20" height="21"/>
</p>
</html>
當我用飛碟HTML轉換爲PDF。生成的PDF不打印圖像。
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);
是否需要使用任何特定包以PDF格式打印圖像。請讓我知道,如果你有任何問題。