【发布时间】:2016-09-28 07:22:15
【问题描述】:
public static final String[] HTML="D:/testing.htm","D:/testing.htm","D:/testing.htm","D:/testing.htm"};
public static final String DEST = ""D:/multiple_html_pages2.pdf";
public static void main(String[] args) throws IOException, DocumentException {
File file = new File(DEST);
file.getParentFile().mkdirs();
new ParseMultipleHtmlFiles2().createPdf(DEST);
}
public void createPdf(String file) throws IOException, DocumentException {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(file));
document.open();
for (String htmlfile : HTML) {
String html = Utilities.readFileToString(htmlfile);
// parsing error are showing there :
ElementList list = XMLWorkerHelper.parseToElementList(htmlfile);
for (com.itextpdf.text.Element e : list) {
document.add(e);
}
document.newPage();
}
document.close();
}
【问题讨论】:
-
我们应该猜猜你得到了什么错误信息吗?
-
XMLWorkerHelper 类型的方法 parseToElementList(String) 未定义
-
从哪个包中导入类?
-
导入 com.itextpdf.tool.xml.XMLWorkerHelper
-
此类中没有名称为
parseToElementList的方法。你在哪里找到这个代码?