Ivan Porto Carrero

Placeholder.Add("Really Cool Stuff");

  Home  |   Contact  |   Syndication    |   Login
  49 Posts | 6 Stories | 170 Comments | 81 Trackbacks

News

Article Categories

Archives

Post Categories

Personal Links

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

}

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Sunday, November 13, 2005 5:26 PM