【发布时间】:2017-07-17 04:16:48
【问题描述】:
我尝试了多个插件和 c# 类来尝试将我的 asp.net 项目中的 HTML 和 CSS 转换为 pdf,即使使用的代码看起来不错,并且按钮单击适用于其他功能,但我似乎无法让任何 html 到 pdf 功能正常工作。有没有其他人遇到过这个问题,或者知道我是否遗漏了什么来解决它?
这是我在 C# 中为 hiqpdf 尝试过的最新代码:
protected void Print_Button_Click(object sender, EventArgs e)
{
HtmlToPdf htmlToPdfConverter = new HtmlToPdf();
// set PDF page size, orientation and margins
htmlToPdfConverter.Document.PageSize = PdfPageSize.A4;
htmlToPdfConverter.Document.PageOrientation = PdfPageOrientation.Portrait;
htmlToPdfConverter.Document.Margins = new PdfMargins(0);
// convert HTML to PDF
htmlToPdfConverter.ConvertUrlToFile("http://localhost:51091/Printout","mcn.pdf");
}
【问题讨论】:
-
不起作用是什么意思?错误?请更具体。
-
嗨@SamiKuhmonen,我运行代码时没有任何反应