开发者

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

开发者 https://www.devze.com 2023-04-10 10:13 出处:网络
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/Firef

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 wit开发者_开发问答h 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.


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.


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.


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.


In regedit use the following steps

1)HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node

2)Create a key DWORD 32 Bit

3) Rename it "w3wp.exe"

4) Set Value Date = 1

0

精彩评论

暂无评论...
验证码 换一张
取 消