从 HTML 页面生成 PDF

3

你好,我有以下代码并尝试将一个html页面转换为pdf。我正在使用abcpdf。

我的代码如下:

Doc theDoc = new Doc();
    theDoc.Rect.Inset(72, 144);

    theDoc.Page = theDoc.AddPage();
    int theID;
    **theID = theDoc.AddImageUrl("http://www.templateworld.com/free_templates.html/");**

    while (true)
    {
        theDoc.FrameRect(); // add a black border
        if (!theDoc.Chainable(theID))
            break;
        theDoc.Page = theDoc.AddPage();
        theID = theDoc.AddImageToChain(theID);
    }

    for (int i = 1; i <= theDoc.PageCount; i++)
    {
        theDoc.PageNumber = i;
        theDoc.Flatten();
    }

    theDoc.Save(Server.MapPath("pagedhtml.pdf"));
    theDoc.Clear();

在以下代码行:

theID = theDoc.AddImageUrl("http://www.templateworld.com/free_templates.html/");

出现了“HTML渲染为空”的错误。我也在Firefox和Chrome上尝试过,使用了其他网址,但仍然出现相同的错误。

有人知道如何解决这个问题吗?


1
你是否阅读并排除了他们支持部分6.7节中列出的故障排除步骤?http://www.websupergoo.com/support.htm - McAden
2个回答

3

1

真正的美国人420和McAden的回答都非常有帮助。

我正在使用Internet Explorer 10上的ABCPDF版本7。我卸载了更新并降级到Internet Explorer 9。现在一切都完美无缺。


ABCpdf .NET适用于当前版本的Windows和Acrobat。因此,最好在当前版本的Windows上使用当前版本的ABCpdf。使用许多年前停止支持的版本是不可取的。请使用当前版本。 - OnceUponATimeInTheWest

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接