Wednesday, November 23, 2011

iTextSharp - Convert html to pdf document

You can create this using two steps as follows:

// step 1: creation of a document-object
  Document document = new Document(PageSize.A4, 80, 50, 30, 65);
  // step 2:
  // we create a writer that listens to the document
  // and directs a XML-stream to a file
  PdfWriter.getInstance(document, new FileStream("file.pdf", FileMode.Create));
  // step 3: we parse the document
  HtmlParser.parse(document, "file.html");

No comments :

Post a Comment