Geeks With Blogs

News
Ivan Porto Carrero Placeholder.Add("Really Cool Stuff");

In a previous article I mentioned iTextSharp as a library that you can use to generate pdf documents from. I couldn't get it to work. Today i downloaded the new version of the library, it was in .NET 1.1 so I converted it to .NET 2 and compiled.

I got some warnings, but nothing alarming ;) Then I started browsing the documentation, compiled the samples ran them and found a sample where they parse html to pdf, but since I've been googling for ages on terms like pdf html .NET and never found something. Today I stumbled upon it and the code to use is realy simple to it are 4 lines or something, here it goes. What is worth more investigating now is can I feed it a string instead of a file or a textwriter or something.  More will come when I found out some more features.

Document document = new Document(PageSize.A4, 80, 50, 30, 65: );

try

{

PdfWriter.GetInstance(document, new FileStream("myNewPdf.pdf", FileMode.Create));

HtmlParser.Parse(document,"myHtml.htm");

}

catch(Exception e)

{

Console.Error.WriteLine(e.Message);

Console.Error.WriteLine(e.StackTrace);

}

Posted on Sunday, November 13, 2005 5:26 PM | Back to top

Copyright © Ivan Porto Carrero | Powered by: GeeksWithBlogs.net