PDA

View Full Version : سوال: خطای Font size too small: 0 در زمان استفاده از iTextSharp



shervin837
دوشنبه 09 بهمن 1391, 13:27 عصر
با سلام به دوستان عزیز من در زمان استفاده از iTextSharp برای تولید فایل pdf از محتویات صفحه به خطای زیر مواجه می شم. البته کد export در جا های دیگه کار می کنه و می تونه مورد استفاده قرار بگیره ولی در این صفحه من خطا میده از جدول با اندازه ثابت هم استفاده کردم ممکنه مشکل از اون باشه؟


Server Error in '/Ank' Application.
--------------------------------------------------------------------------------

Font size too small: 0

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: System.ArgumentException: Font size too small: 0

Source Error:


Line 107: pdfDoc.Open();
Line 108: FontFactory.RegisterDirectories();
Line 109: htmlparser.Parse(sr);
Line 110: pdfDoc.Close();
Line 111: Response.Write(pdfDoc);


Source File: d:\Dev\Ank\Bd.aspx.cs Line: 109

Stack Trace:


[ArgumentException: Font size too small: 0]
iTextSharp.text.pdf.PdfContentByte.SetFontAndSize( BaseFont bf, Single size) +401
iTextSharp.text.pdf.PdfDocument.WriteLineToContent (PdfLine line, PdfContentByte text, PdfContentByte graphics, Object[] currentValues, Single ratio) +5359
iTextSharp.text.pdf.ColumnText.Go(Boolean simulate) +1830
iTextSharp.text.pdf.ColumnText.GoComposite(Boolean simulate) +4659
iTextSharp.text.pdf.ColumnText.Go(Boolean simulate) +138


و کد Export to PDF:


private void PDF_Export()
{

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
Response.Charset = "utf-8";
Response.Cache.SetCacheability(HttpCacheability.No Cache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
div1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
FontFactory.RegisterDirectories();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}

shervin837
جمعه 13 بهمن 1391, 01:52 صبح
دوستان در این رابطه اطلاعاتی ندارید؟