Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert HTML to PDF - Any library for ASP.net [closed]

Tags:

.net

asp.net

pdf

Is there any .net library which would convert a HTML output to PDF --- in an asp.net application.

Doesn't matter if it is free or not

like image 453
soldieraman Avatar asked Jan 13 '11 07:01

soldieraman


People also ask

How do I convert HTML to PDF automatically?

On a Windows computer, open an HTML web page in Internet Explorer, Google Chrome, or Firefox. On a Mac, open an HTML web page in Firefox. Click the “Convert to PDF” button in the Adobe PDF toolbar to start the PDF conversion. Enter a file name and save your new PDF file in a desired location.


2 Answers

Based on my own experience I'd suggest ABCpdf library (it's not free, but you can get a trial license). Check out their documentation section for how to add HTML output to the PDF document.

Quick example:

string html = "<html>....</html>";
WebSupergoo.ABCpdf7.Doc doc = new WebSupergoo.ABCpdf7.Doc();

doc.Rect.Left = 10;
doc.Rect.Bottom = 50;
doc.Rect.Top = 750;
doc.Rect.Right = 600;    

doc.SetInfo(0, "License", "[your license code || trial license"]);    
doc.Page = doc.AddPage();

int pageID = doc.AddImageHtml(html, true, 1024, true);
while (doc.Chainable(pageID))
{
    doc.Page = doc.AddPage();
    pageID = doc.AddImageToChain(pageID);
}

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

doc.Save("myfile.pdf");

Hope this will help you.

like image 150
volpav Avatar answered Sep 28 '22 04:09

volpav


If you don't care the price, Aspose and Price are the best of its likes. Excellent fonts rendering, standard support.

like image 29
J-16 SDiZ Avatar answered Sep 28 '22 03:09

J-16 SDiZ