Nuget 引入 OpenHtmlToPdf
1 using (WebClient wc = new WebClient()) 2 { 3 wc.Encoding = Encoding.UTF8; 4 wc.UseDefaultCredentials = true; 5 string html = wc.DownloadString(URL); 6 7 var document = Pdf.From(html); 8 9 var result = document.Content(); 10 11 var ms = new System.IO.MemoryStream(result); 12 var fn = string.Format("quotation_{0}", filenme); 13 14 return new Attachment(ms, fn, "application/pdf"); 15 }
本文介绍如何通过NuGet引入OpenHtmlToPdf库,并使用C#代码将网页HTML内容转换成PDF文件,具体展示了从指定URL下载HTML字符串,再将其转化为PDF并保存到内存流的全过程。
1099

被折叠的 条评论
为什么被折叠?



