我正在使用Visual Studio 2008,我需要在按钮点击事件中转换一些stringbulider文本并获取pdf格式输出文件。
以下是示例stringbuilder文本。
StringBuilder reqReport = new StringBuilder();
reqReport.Append("<li>Five copies of your latest Passport size.</li>");
reqReport.Append("<li>Your certificates, testimonials etc. (in original with one photocopy)</li>");
reqReport.Append("<li>Residence & Identity proof required in Bank account opening process as per RBI guidelines.</li>");
我尝试使用itextsharp ..
string html = reqReport.ToString();
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
System.Xml.XmlTextReader _xmlr = new System.Xml.XmlTextReader(new StringReader(html));
HtmlParser.Parse(pdfDoc, _xmlr);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Table.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
这会创建pdf文件..但是当我尝试打开文件时,它会显示文件已损坏或已损坏且无法打开..
是否还有其他格式来执行此功能..?
提前致谢...