【问题标题】:c# html to Pdf Converter(Nreco)c# html to Pdf Converter(Nreco)
【发布时间】: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


    【解决方案1】:

    我已通过将 NReco.PdfGenerator.dll 更新到 1.1.11.0 版本来修复它,使用的是过期版本(3 年前发布)并且错误消失了。

    注意:当我使用 Nuget 包管理器卸载和安装 Nreco 时,它安装的是相同的旧版本,我不知道为什么,所以我不得不从以下位置下载它:

    https://pdfgenerator.codeplex.com/

    并从项目的引用中手动删除旧的 .dll 并添加新的 NReco.PdfGenerator.dll

    【讨论】:

    • 您好,我正在使用 NReco.PdfGenerator.dll。我观察到 wkhtmltopdf.exe、msvcp120.dll、msvcr.dll 在根目录中创建外部 bin。你有同样的经历吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-15
    • 1970-01-01
    • 2016-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    相关资源
    最近更新 更多