Click here to Skip to main content
14,383,822 members

Font size too small: 0

Member 14192879 asked:

Open original thread
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\WORK-PC-5\Desktop\important\recent\miguide\miguide\TC.aspx.cs    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\WORK-PC-5\Desktop\important\recent\miguide\miguide\TC.aspx.cs:1668
   miguide.WebForm25.Page_Load(Object sender, EventArgs e) in C:\Users\WORK-PC-5\Desktop\important\recent\miguide\miguide\TC.aspx.cs: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);//Name of the Panel
            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);
Tags: C#, ASP.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100