2

我有 ASP .Net 框架 4.7 Web 表单应用程序。

我正在使用 EvoHtmlToPdf v8.0 将 ASP .net 表单转换为 pdf。我正在使用 EvoHtmlToPdf v8.0 的默认通用版本,该版本应在 32 位和 64 位环境中工作。

我在代码中遇到错误htmlToPdfConverter.ConvertUrl(url);

仅在“本地 IIS”中运行项目时出现此错误,但在 Visual Studio 的项目设置中将其设置为“IIS Express”时没有出现错误

无法开始转换。WinApi 错误代码 5. 检查 'evointernal.dat' 文件是否具有执行权限以及它是否存在于 evohtmltopdf.dll 附近或使用 evointernal.dat 文件的完整路径设置 EvoInternalFileName 属性

这是我的 asp .net c sharp 代码的完整代码

            public static byte[] convertToPdf(string url)
        {
            // Create a HTML to PDF converter object with default settings
            HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();

            // Set license key received after purchase to use the converter in licensed mode
            // Leave it not set to use the converter in demo mode
            htmlToPdfConverter.LicenseKey = Constants.SystemSettings.PDF_LicenseKey;

            // Set HTML Viewer width in pixels which is the equivalent in converter of the browser window width
            htmlToPdfConverter.HtmlViewerWidth = Utility.getConfirmInteger(Constants.SystemSettings.PDF_HtmlViewerWidth)==0? HtmlViewerWidthDefault : Utility.getConfirmInteger(Constants.SystemSettings.PDF_HtmlViewerWidth);

            // Set HTML viewer height in pixels to convert the top part of a HTML page 
            // Leave it not set to convert the entire HTML
            if (Utility.getConfirmInteger(Constants.SystemSettings.PDF_HtmlViewerHeight) != 0)
            {
                htmlToPdfConverter.HtmlViewerHeight = Utility.getConfirmInteger(Constants.SystemSettings.PDF_HtmlViewerHeight);
            }

            // Set PDF page size which can be a predefined size like A4 or a custom size in points 
            // Leave it not set to have a default A4 PDF page
            htmlToPdfConverter.PdfDocumentOptions.PdfPageSize = SelectedPdfPageSize();

            // Set PDF page orientation to Portrait or Landscape
            // Leave it not set to have a default Portrait orientation for PDF page
            htmlToPdfConverter.PdfDocumentOptions.PdfPageOrientation = SelectedPdfPageOrientation();

            // Set an adddional delay in seconds to wait for JavaScript or AJAX calls after page load completed
            // Set this property to 0 if you don't need to wait for such asynchcronous operations to finish
            htmlToPdfConverter.ConversionDelay = Utility.getConfirmInteger(Constants.SystemSettings.PDF_ConversionDelay);

            return htmlToPdfConverter.ConvertUrl(url);
        }
4

1 回答 1

1

我通过将应用程序池身份帐户的权限授予包含项目二进制文件的文件夹来解决问题

于 2021-08-29T00:28:21.517 回答