Search code examples
c#asp.netimageabcpdf

Transition from ABCpdf07 to ABCpdf8 - images are not displayed


I am trying to make the transition from ABCpdf07 to ABCpdf8. We use this in methods for printing various shipping labels in PDF format. This generally works, with the exeption of files with images in them. Here is the code used for putting in the html to the Document:

    public void AddHtml(string html, string frame, string nextPageFrame)
    {
        if (string.IsNullOrEmpty(nextPageFrame))
            nextPageFrame = frame;
        Document.Units = UnitType.Mm;
        Document.Rect.String = frame;

        int i = Document.AddImageHtml(html);

        while (true)
        {
            if (!Document.Chainable(i))
                break;
            Document.Page = Document.AddPage();
            Document.Rect.String = nextPageFrame;
            i = Document.AddImageToChain(i);
        }

        for (int j = 1; j <= Document.PageCount; j++)
        {
            Document.PageNumber = j;
            Document.Flatten();
        }
    }

frame and nextFrame are simply values determining how large the pages are. The html works in debugging when I view it in HTML view. But after this method, when the Document gets saved, the images are not shown on the page - in stead there's the broken-image-icon. The images are saved locally in the project folder (c:\etc...). Have tripple-checked that the links are working.

Really cant wrap my head around why the images aren't displayed properly. Any help?

Edit: My xslt document finds the image like this

    <xsl:template match="//TheWrapper">
    ...
    <img class="someClass">
       <xsl:attribute name="src">
          <xsl:value-of select ='LogoLocation' />
       </xsl:attribute>
    </img>
    ...
    </xsl:template>

Solution

  • It seems version 8 of ABCpdf has another method of passing the images. This is because they wanted to not be dependant on IE (which it loads in the background some time during the processing). I'm not very knowledgable with the details here.

    Anyway - Happened to open the logo filepath in Chrome, and it added 'file:///' automatically, so I tried doing that in my code, and it worked! Simply prefix the logo filepaths with 'file:///' and everything works fine.