我正在使用itext和xmlworker创建pdf格式xml / html,因为我正在使用下面的代码
public class XmlWorkerEx implements TagProcessor{
public static void main(String[] args) throws IOException, DocumentException{
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("result.pdf"));
document.open();
HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true);
Pipeline<?> pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext,new PdfWriterPipeline(document, writer)));
XMLWorker worker = new XMLWorker(pipeline, true);
XMLParser p = new XMLParser(worker);
p.parse(new FileInputStream("form.html"));
document.close();
}
和我的HTML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
<html>
<head>
<style type="text/css">
.name{ font: 16px georgia ; }
.fl{float:left;width:100%; font: 16px georgia; }
.message {margin: 15px 0;width:500px;}
.sign span{ margin-top:5px; }
</style>
</head>
<body>
<div id="firstname"> Firstname ,</div>
<div class="message fl">
<P> Firstname is informed that This exemption is in accordance with Title 45 of the Code of Federal Regulations Part
46.102 (d) “a systematic investigation, including research development, testing, and evaluation, </p>
</div>
</body>
</html>
现在我想更改ID为firstname
的div的内容...怎么做?