I have a html content in a variable.
I want to create a PDF document on button click with using iTextSharp dll. I searched on Google, how my PDF document can understand my HTML content, so i got HTMLWorker, it works but i don't how it's working.
How this code will work to create PDF document (that can understand my HTML content).
What's the use of HTMLWorker class in this code.
If any other better way to do this, then please suggest.
Can you make me understand the process of this code. It's very important for me.
Document PdfDoc = new Document(PageSize.A4);
PdfWriter write = PdfWriter.GetInstance(PdfDoc, Response.OutputStream);
TextReader reader = new StringReader(paragraphBlogContent.InnerText);
HTMLWorker worker = new HTMLWorker(PdfDoc);
PdfDoc.Open();
worker.StartDocument();
worker.Parse(reader);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;" + "filename=sample.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(PdfDoc);
worker.EndDocument();
worker.Close();
PdfDoc.Close();