1

出于某种原因,我无法弄清楚导致 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
  }
}
4

2 回答 2

1

为了解决这个问题,我卸载了用于自动安装的 ABCPDF。从 bin 文件夹中删除所有 DLL。然后我按照此处的说明手动安装了 DLL

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

于 2017-12-27T20:58:22.240 回答
0

我收到了错误Unable to start ABCChrome engine

就我而言,ABCPdf 是通过 nuget package manager 添加的,而不是直接安装在目标服务器上。

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

于 2018-11-09T00:14:27.017 回答