Android HTML到PDF的图像转换
我在将HTML结构中的图像解析为PDF文件时遇到问题,我尝试使用以下行收集图像,但是创建的PDF文件中没有图像。我将iText与xmlworker库一起使用,html全部存储在字符串中,然后解析为输入流,如下代码所示Android HTML到PDF的图像转换,android,html,itext,xmlworker,Android,Html,Itext,Xmlworker,我在将HTML结构中的图像解析为PDF文件时遇到问题,我尝试使用以下行收集图像,但是创建的PDF文件中没有图像。我将iText与xmlworker库一起使用,html全部存储在字符串中,然后解析为输入流,如下代码所示 ..... <img class='top' src='file:///android_res/drawable/logo.png' height='100px' width='200px'/> ........ ........ InputStream is = ne
.....
<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);
。。。。。
........
........
InputStream is=newbytearrayinputstream(str.getBytes())//包含html字符串
XMLWorkerHelper.getInstance().parseXHtml(编写器、文档、is);
您可能应该使用自己的ImageProvider来获取图像。()
此接口有4种方法:
- getImageRootPath()
- 重置()
- 检索(字符串src)
- 存储(字符串src,图像img)
关于XMLWorker的文档:这最终使我找到了所需的正确实例。谢谢