标签:cep css bytes nbsp already stream develop var bsp
地址: https://developers.itextpdf.com/examples/xml-worker/html-lists
主方法:
public string Generate(string filePath)
{
if (DeleteOldFile(filePath))
{
throw new Exception("the destination path already existed and unable to repleace it");
}
var fs = new FileStream(filePath, FileMode.Create);
var doc = new Document(PageSize.B4);
var pdfWriter = PdfWriter.GetInstance(doc, fs);
doc.Open();
var html = this.GetTemplate();
var css = this.GetCSS();
using (var msCss = new MemoryStream(Encoding.UTF8.GetBytes(css)))
{
using (var msHtml = new MemoryStream(Encoding.UTF8.GetBytes(html)))
{
XMLWorkerHelper.GetInstance().ParseXHtml(pdfWriter, doc, msHtml, msCss);
}
}
doc.Close();
fs.Close();
pdfWriter.Close();
return filePath;
}
标签:cep css bytes nbsp already stream develop var bsp
原文地址:https://www.cnblogs.com/zxhome/p/9368890.html