DLL iTextsharp- Used to Create PDF in ASP.NET
itextsharp.dll used to create pdf document in Dot Net.
private void CreateMyPDF()
{
Document doc = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.GetInstance(doc, new
FileStream("C:\\lakhan.pdf", FileMode.Create));
doc.Open();
string strURL = "http://wiziq.com/index.aspx";
Uri uri = new Uri(strURL);
//Create the request object
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
req.UserAgent = "Get Content";
WebResponse resp = req.GetResponse();
Stream stream = resp.GetResponseStream();
StreamReader sr = new StreamReader(stream);
string html = sr.ReadToEnd();
ArrayList lt = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(html), null);
ColumnText ct = new ColumnText(writer.DirectContent);
ct.SetSimpleColumn(50, 50, PageSize.A4.Width - 50, PageSize.A4.Height - 50);
for (int k = 0; k < lt.Count; ++k) {
ct.AddElement((IElement)lt[k]);
}
ct.Go();
doc.Close();
}
Hi
Thanks for ur code.
But i'm unable to get "PdfWriter" object.Which reference/class shall i needs to import to get it.
Is there any .dll needs to be downloaded to use this object.
Thanks & Regards
Guru Prasad