Font size too small: 0
I think maybe an error because pdf has more than 1 page and it creates all pages of pdf on 1 page
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: iTextSharp.text.DocumentException: Font size too small: 0
Source Error:
Line 1666: StringReader s_tr = new StringReader(s_tw.ToString());
Line 1667: HTMLWorker html_worker = new HTMLWorker(doc);
Line 1668: html_worker.Parse(s_tr);
Line 1669: doc.Close();
Line 1670: Response.Write(doc);
Source File: C:\Users\ Line: 1668
Stack Trace:
[DocumentException: Font size too small: 0]
iTextSharp.text.pdf.PdfDocument.Add(IElement element) +6159
iTextSharp.text.Document.Add(IElement element) +176
iTextSharp.text.html.simpleparser.HTMLWorker.ProcessTable() +89
iTextSharp.text.html.simpleparser.HTMLTagProcessor_TABLE.EndElement(HTMLWorker worker, String tag) +68
iTextSharp.text.html.simpleparser.HTMLWorker.EndElement(String tag) +52
iTextSharp.text.xml.simpleparser.SimpleXMLParser.Go(TextReader reader) +1367
iTextSharp.text.html.simpleparser.HTMLWorker.Parse(TextReader reader) +78
miguide.WebForm25.sll() in C:\Users:1668
miguide.WebForm25.Page_Load(Object sender, EventArgs e) in C:\Users:38
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
System.Web.UI.Control.OnLoad(EventArgs e) +97
System.Web.UI.Control.LoadRecursive() +61
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693
What I have tried:
string attachment = "attachment; filename=" + "abc" + ".pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/pdf";
StringWriter s_tw = new StringWriter();
HtmlTextWriter h_textw = new HtmlTextWriter(s_tw);
h_textw.AddStyleAttribute("font-size", "7pt");
h_textw.AddStyleAttribute("color", "Black");
this.Page.RenderControl(h_textw);
Document doc = new Document();
doc = new Document(PageSize.A4, 5, 5, 15, 5);
FontFactory.GetFont("Times New Roman", 14);
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
StringReader s_tr = new StringReader(s_tw.ToString());
HTMLWorker html_worker = new HTMLWorker(doc);
html_worker.Parse(s_tr);
doc.Close();
Response.Write(doc);