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 上尝试了同样的方法。我也尝试使用其他网址。我犯了同样的错误。

有人知道这个问题的任何解决方案吗?

4

2 回答 2

3

查看其他 Stack Overflow 文章。也许它会帮助你。

ABCPDF6 问题:“HTML 渲染为空白”,但网页输出正常

于 2013-07-30T20:27:30.267 回答
1

trueamerican420 和 McAden 的回答确实有帮助。

我在 Internet Explorer 10 上使用 ABCPDF 版本 7。我删除了更新并降级到 Internet Explorer 9。现在一切正常

于 2013-08-01T13:38:52.293 回答