Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 611
CodeNinja Avatar asked May 12 '26 22:05

CodeNinja


1 Answers

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

like image 102
trueamerican420 Avatar answered May 14 '26 13:05

trueamerican420



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!