使用iTextSharp将HTML转换为PDF时出现“Stack Empty”错误 [英] 'Stack Empty' error when using iTextSharp for converting HTML to PDF
本文介绍了使用iTextSharp将HTML转换为PDF时出现“Stack Empty”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
' Stack Empty '错误。
我的代码片段:
'Stack Empty' error when using iTextSharp for converting HTML to PDF.
My code snippet:
dg1.Columns[11].Visible = false;
string attachment = "attachment; filename=AllPage.pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/pdf";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
form1.RenderControl(htextw);
Document document = new Document();
PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
StringReader str = new StringReader(stw.ToString());
HTMLWorker htmlworker = new HTMLWorker(document);
htmlworker.Parse(str);//stack empty
document.Close();
Response.Write(document);
Response.End();
推荐答案
请参阅以下有用的链接: http://www.eggheadcafe.com/community/csharp/2/10151279/convert- html-string-to-pdf-using-itextsharp.aspx [ ^ ]
Refer the useful link at: http://www.eggheadcafe.com/community/csharp/2/10151279/convert-html-string-to-pdf-using-itextsharp.aspx[^]
确保不要关闭HTML模板中的表并添加它通过代码 -
Make sure you do not close the table in HTML template and add it via code -
"</table>"
这篇关于使用iTextSharp将HTML转换为PDF时出现“Stack Empty”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文