Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ABCPDF6 issue: "HTML render is blank" but web page output is fine

Tags:

abcpdf

Like the title says, we are using ABCPdf6 to render PDFs from XSLT. Everything was working fine, but now we are getting an error that states "HTML render is blank". Using a browser (tested on IE/Firefox/Chrome) I am able to browse to the generated HTML (formatted XSL) and it displays perfectly fine in the browser. ABCPDF6 is not able to convert the file. I have tried giving control to the page that outputs the XSL, but I am still getting this error.

Does anyone have experience with ABCPdf and have encountered this before? The code was working fine before without a problem, and another page that uses the exact same generating code (even pointing to the same placeholder page that spits out the HTML!) is working fine.

like image 461
Wayne Molina Avatar asked Oct 04 '11 19:10

Wayne Molina


3 Answers

I know what the problem was in my case now. When i ran Windows update on my 2008 server, Internet Explorer 9 was installed. IE 9 has a different way of rendering HTML which brakes abcPDF. Updating to the latest version (8) solved all my problems. In this version you can also try another HTML engine called Gecko.

Even though you have resolved your problem, if anyone else gets this error, I would suggest that you install the trial version and try this out with the latest version.

like image 74
Andreas Avatar answered Nov 20 '22 15:11

Andreas


I had same error on windows 7 machine with AbcPdf4.0. During MS updates IE8 was upgraded to IE10. Issue got fixed by uninstalling IE10.

Note: Abcpdf4.0 does not work with IE9 onwards. Either upgrade Abcpdf or uninstall latest IE.

like image 3
user2160054 Avatar answered Nov 20 '22 14:11

user2160054


I had a similar issue this morning with AbcPdf9. I added code to test the engine types and GECKO worked, then I swapped it back to MSHTML, and it still worked. So it was a temporary issue.

This is how you specify the engine type:

using (var document = new Doc())
{
    document.HtmlOptions.Engine = EngineType.Gecko;
    ...
    ...
}

This code calls the method that converts the html to PDF, but calls it twice if necessary, since it will only fail once:

try
{
    return GeneratePdfFromHtml(html, width, EngineType.MSHtml);
}
catch (Exception ex)
{
    /* detect this known issue, swapping the rendering engine once seems to fix it */
    if (ex.Message.ToUpper().Contains("BLANK"))
    {
        return GeneratePdfFromHtml(html, width, EngineType.Gecko);
    }
    throw;                            
}

Then you can add a parameter to the method that does the conversion:

    public byte[] GeneratePdfFromHtml(string html, int width, EngineType engineType)
    {
        if (string.IsNullOrWhiteSpace(html)) throw new ArgumentNullException("html");
        if (width < 100) throw new ArgumentOutOfRangeException("width");

        try
        {
            using (var document = new Doc())
            {
                document.HtmlOptions.Engine = engineType;
                ...
                ...

If you have a suggestion or different solution, please leave a comment.

like image 1
Martin Lottering Avatar answered Nov 20 '22 14:11

Martin Lottering