【发布时间】:2016-04-19 20:59:39
【问题描述】:
我正在为我的项目使用 NReco html 到 pdf 转换器。 它在服务器机器上给了我 3 天的错误,它工作了几个月没有任何问题。更糟糕的是,该项目在我的本地电脑上运行良好,具有相同的代码。我猜,问题与某些文件夹自动化或已经在服务器 pc 上创建的临时文件。我还删除了 /user 和 windows/temp 文件夹下的临时文件,但仍然出现错误:
简单的错误信息是:“文件存在”
代码:
public static byte[] ToPDF(this HttpContext context, string htmlContent )
{
string logFile = context.Request.PhysicalApplicationPath + "\\" + "log.txt";
try
{
var converter = new HtmlToPdfConverter();
converter.Margins = new PageMargins { Bottom = 20, Top = 18 };
var pdfBytes = converter.GeneratePdf(htmlContent); //THROW EXCEPTION ON THIS LINE
errorMsg = "Error Code:00x1";
return null;
}
catch (Exception exp)
{
errorMsg = "Error Code:00x2";
CreateErrorLog(context ,exp);
return null;
}
}
【问题讨论】:
标签: c# asp.net pdf pdf-generation wkhtmltopdf