找不到 ABCChrome、WebSupergoo。ABCpdf11.Internal.PDFException

Could not find ABCChrome, WebSupergoo.ABCpdf11.Internal.PDFException

出于某种原因,我无法弄清楚是什么导致了 ABCpdf 出现此错误。我们正在从 v9 升级到 v11。我们已尝试包含 dll 和一个参考,但似乎都不起作用。

出错的行在docPDF.AddImageHtml(strHTML);

我们正在使用 Webforms 网站和 IIS。

An exception occurred: WebSupergoo.ABCpdf11.Internal.PDFException: Could not find ABCChrome. 
at WebSupergoo.ABCpdf11.Internal.Chrome.ABCChromePool.GetABCChromePath() 
at WebSupergoo.ABCpdf11.Internal.Chrome.ABCChromePool.GetWorker(IHtmlChromeOptions options) at WebSupergoo.ABCpdf11.Internal.Chrome.ABCChromePages.AddImageUrl(String url) 
at WebSupergoo.ABCpdf11.Internal.Chrome.ABCChromePages.AddHtml(String html) 
at WebSupergoo.ABCpdf11.Doc.AddUrlHtml(String urlOrHtml, Boolean isHtml, Boolean paged, Int32 width, Boolean disableCache) 
at WebSupergoo.ABCpdf11.Doc.AddImageHtml(String html, Boolean paged, Int32 width, Boolean disableCache) at WebSupergoo.ABCpdf11.Doc.AddImageHtml(String html) 
at VIGWorker.GeneratePDF() in c:\dev\ClarityFoundations\CFWebsite\Client\VG\pages\VG_VisualIndexGen.aspx.cs:line 1249

函数调用

public void GenerateTestPDF(string strHTML) {
  try
  {
        // Using trial license for v11
        // Install the license
        string strLicense = App.Model.Parm.GetValue("REPORT-PDF-ABCPDF-LICENSE");
        if (!string.IsNullOrEmpty(strLicense))
        {
            XSettings.InstallLicense(strLicense);
        }

        // Load the CMS header and footer
        string strHeader = CMS.GetContentHTML_ShowError("My_Header");
        string strFooter = CMS.GetContentHTML_ShowError("My_Footer");

        // Create new PDF Document object:
        Doc docPDF = new Doc();

        // Setup the main document parameters
        docPDF.TopDown = true;

        // Portrait layout. Page is 8.5x11 inches, at 72 pixels per inch
        docPDF.MediaBox.Width = (8.5 * 72); // 612 pixels
        docPDF.MediaBox.Height = (11 * 72); // 792 pixels

        // We want a body rect that has 1/2 inch margin on right and left, and 1 inch on top and bottom for header and footer.
        docPDF.Rect.String = docPDF.MediaBox.ToString();
        docPDF.Rect.Inset(36, 72); // 1/2 inch margin on right and left, 1 inch on top and bottom for header/footer

        iItemsPerRow = 3;
        iRowsPerPage = 5;

        //Figure out maximum picture size based on page size and items per page
        // WIDTH: We want ~10 pixels on sides and in between columns
        int iPageWidth = (int)docPDF.Rect.Width;
        iMaxImageWidth = (iPageWidth - (10 * (iItemsPerRow + 1))) / iItemsPerRow;

        // HEIGHT: We want ~10 pixels on all sides and in between rows, and also about 60 for text below picture.
        int iPageHeight = (int)docPDF.Rect.Height;
        iMaxImageHeight = (iPageHeight - ((10 * (iRowsPerPage + 1)) + (60 * iRowsPerPage))) / iRowsPerPage;

        // Calculate the ration to use when comparing image height to width, and the CSS to use depending on which one we choose.
        fImageRatio = (float)iMaxImageWidth / (float)iMaxImageHeight;
        strImageCSSByWidth = "width:" + iMaxImageWidth.ToString() + "px; height:auto;";
        strImageCSSByHeight = "height:" + iMaxImageHeight.ToString() + "px; width:auto;";

        // Get the F/L/FL icon locations
        strFIcon = strBaseURL + "/Images/VI_Icon_F.png";
        strLIcon = strBaseURL + "/Images/VI_Icon_L.png";
        strFLIcon = strBaseURL + "/Images/VI_Icon_FL.png";

        // Start on page 1
        docPDF.Page = 1;

        if (!string.IsNullOrWhiteSpace(strHTML))
        {
            int iTextID = docPDF.AddImageHtml(strHTML);
            while (docPDF.Chainable(iTextID))
            {
                docPDF.Page = docPDF.AddPage();
                iTextID = docPDF.AddImageToChain(iTextID);
            }
        }

        // Write the PDF file to disk
        byte[] bytBuffer = docPDF.GetData();

        // Cleanup
        docPDF.Dispose();

        using (FileStream fs = File.Create(strFilePath))
        {
            fs.Write(bytBuffer, 0, bytBuffer.Length);
        }
  }
  catch(Exception ex) {
    // do something with the exception
  }
}

要解决此问题,我所做的是卸载 ABCPDF 以进行自动安装。从 bin 文件夹中删除了所有 DLL。然后我按照找到的说明手动安装了 DLL here.

然后 ABC PDF 开始正常工作。似乎 ABC PDF .net 的自动安装导致手动安装出现问题。

我收到错误 Unable to start ABCChrome engine

在我的例子中,ABCPdf was added via nuget package manager,而不是直接安装在目标服务器上。

我的解决方案是停止我的服务,进入任务管理器并终止 ABCPdf 进程,然后重新启动我的服务。