abcpdfabcpdf9

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


For some reason I can't figure out what is causing this error with ABCpdf. We are upgrading from v9 to v11. We have tried including the dlls and just a reference but neither appear to be working.

The line that the error occurs is on docPDF.AddImageHtml(strHTML);

We are using a Webforms website and 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

Function Call

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
  }
}

Solution

  • To fix this issue what I did was uninstalled ABCPDF for Automatic installation. Removed all DLLs from the bin folder. Then I manually installed the DLLs following the instructions found here.

    Then ABC PDF started working as normal. Appeared as though an automatic installation of the ABC PDF .net was causing issues with manual installation.