C#中是否有XMLWorkerHelper的示例?

时间:2011-06-16 11:27:49

标签: asp.net

我想在c#中使用以下代码。我需要向我的项目添加什么,以便以下代码可以正常工作。

Document doc = new Document(PageSize.A4);

PdfWriter writer = PdfWriter.getInstance(doc, 
 new FileOutputStream(new File("./target/test-classes/examples/columbus2.pdf")));

doc.open();

HtmlPipelineContext htmlContext = new HtmlPipelineContext();

htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());

CSSResolver cssResolver = 
    XMLWorkerHelper.getInstance().getDefaultCssResolver(true);

Pipeline<?> pipeline = new CssResolverPipeline(cssResolver, 
    new HtmlPipeline(htmlContext , new PdfWriterPipeline(doc, writer)));

XMLWorker worker = new XMLWorker(pipeline, true);

XMLParser p = new XMLParser(worker);

p.parse(XMLWorkerHelperExample.class.getResourceAsStream("columbus.html"));

doc.close();

1 个答案:

答案 0 :(得分:2)

这看起来像是iText PDF Library的代码。

这是F / OSS软件,可以downloaded here或直接来自SourceForge here

从那里开始,你将把你的图书馆的DLL包含在你的项目中,你就会好起来!