我嘗試解析html文件並生成pdf。我使用代碼ITextSharp:用西里爾文/國際詞語解析html
document.Open();
HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(true);
IPipeline pipeline =
new CssResolverPipeline(cssResolver,
new HtmlPipeline(htmlContext,
new PdfWriterPipeline(document, writer)));
XMLWorker worker = new XMLWorker(pipeline, true);
XMLParser p = new XMLParser(true, worker, Encoding.Unicode);
p.Parse((TextReader)File.OpenText(@"Template.html"));
document.Close();
如何定義基本字體,如果我想使用西裏爾字母/國際字?
看看這篇文章的幫助http://stackoverflow.com/questions/10329863/display-unicode-characters-in-converting-html-to-pdf – 2012-07-20 13:45:24