Export Html to PDF using ITextsharp
50,952
Try this:
Document document = new Document();
PdfWriter.GetInstance(document, new FileStream(Request.PhysicalApplicationPath + "\\MySamplePDF.pdf", FileMode.Create));
document.Open();
iTextSharp.text.html.simpleparser.HTMLWorker hw =
new iTextSharp.text.html.simpleparser.HTMLWorker(document);
hw.Parse(new StringReader(htmlText));
document.Close();
![Qaisar Shabbir Awan](https://i.stack.imgur.com/iaOgg.jpg?s=256&g=1)
Author by
Qaisar Shabbir Awan
Updated on July 09, 2022Comments
-
Qaisar Shabbir Awan almost 2 years
I have tried the code below, I am also facing an error. I am using latest DLL.
String strSelectUserListBuilder = @"<html><body> <h1>My First Heading</h1> <p>My first paragraph.</p> </body> </html>"; String htmlText = strSelectUserListBuilder.ToString(); List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);
I got this error:
The given key was not present in the dictionary.