Convert HTML to PDF using HtmlRenderer [closed]

妖精的绣舞 提交于 2019-12-12 07:39:33

问题


I am looking to use HtmlRenderer to convert an HTML file to a PDF file. I have seen it being mentioned on several sites that it is possible. However, I don't seem to be able to find any basic sample code to do this.

I have added the following NuGet package.

Install-Package HtmlRenderer.PdfSharp

That's about as far I have got. Any help will be greatly appreciated.


回答1:


Found a solution:

using TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator;

string html = File.ReadAllText("input.htm");
PdfDocument pdf = PdfGenerator.GeneratePdf(html, PageSize.Letter);
pdf.Save("document.pdf");


来源:https://stackoverflow.com/questions/40431583/convert-html-to-pdf-using-htmlrenderer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!