小编Tom*_*Ufx的帖子

基于HTML代码生成PDF(iTextSharp,PDFSharp?)

PDFSharp是否可以像iTextSharp一样生成PDF文件*考虑HTML格式*?(粗体(强),间距(br)等)

以前我使用iTextSharp并以这种方式粗略处理(下面的代码):

 string encodingMetaTag = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
 string htmlCode = "text <div> <b> bold </ b> or <u> underlined </ u> <div/>";

 var sr = new StringReader (encodingMetaTag + htmlCode);
 var pdfDoc = new Document (PageSize.A4, 10f, 10f, 10f, 0f);
 var = new HTMLWorker htmlparser (pdfDoc);
 PdfWriter.GetInstance (pdfDoc, HttpContext.Current.Response.OutputStream);
 pdfDoc.Open ();
 htmlparser.Parse (sr);
 pdfDoc.Close ();
Run Code Online (Sandbox Code Playgroud)

将适当的HTML表单合并到处理类对象HTMLWorker的PDF文档中..那么用PDFSharp做什么?有PDFSharp类似的解决方案吗?

html c# pdf pdfsharp itextsharp

18
推荐指数
4
解决办法
6万
查看次数

标签 统计

c# ×1

html ×1

itextsharp ×1

pdf ×1

pdfsharp ×1