CodeNinja
CodeNinja

Reputation: 3278

Render a pdf from a html page

Hello I have the following code and I am trying to convert a html page into a pdf. I am using abcpdf.

My code is below :

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();

At the following line :

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

it throws an error saying "HTML render is blank". I tried the same on Firefox and chrome too. I tried using other urls too. I get the same error.

Anyone know of any solution to this problem ?

Upvotes: 3

Views: 2402

Answers (2)

CodeNinja
CodeNinja

Reputation: 3278

Both the answers by trueamerican420 and McAden really helped.

I am using ABCPDF version 7 on Internet explorer 10. I removed the update and downgraded to internet explorer 9. and everything works perfectly now

Upvotes: 1

trueamerican420
trueamerican420

Reputation: 221

Check out this other Stack Overflow article. Maybe it will help you out.

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

Upvotes: 3

Related Questions