PDF下载问题 [英] Pdf download problem
本文介绍了PDF下载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张Microsoft图表.我想在单击按钮时将该图表导出为pdf.
这是我在单击按钮时的代码.
Hi,
I have one Microsoft chart. I want to export that chart into pdf on button click.
This is my code in button click.
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=ForwardLoadHistory.pdf");
Response.ContentType = "application/pdf";
Response.Charset = "";
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
chtEstHoursRemaining.RenderControl(htmlWriter);
Response.Output.Write(stringWriter.ToString());
Response.Flush();
Response.End();
文件正在下载.它正在正确呈现.当我在写字板中打开文件时,它会正确显示渲染的文本,但是当我尝试打开文件时,它会出现以下错误.
File is downloading .It is rendering properly. When i open file in wordpad it is properly showing rendered text but when i try to open file it is giving following error.
" Adobe reader could not open file 'ForwardLoadHistory.pdf' because it is either not a supported file type or because the file has been damaged(for example it was sent as an email attachment and wasn't corrcetly decoded)".
我尝试使用ITextSharp做到这一点,但在解析时却出现以下错误.
I try to do it with ITextSharp but is giving me following error while parsing.
Illegal characters in path
请提供一些有用的解决方案.
Please give some helpful solution.
推荐答案
阅读以下内容: ^ ]
Read the following : http://stackoverflow.com/questions/5401216/how-to-export-ms-chart-control-to-pdf[^]
嗨
试试这个
Response.AppendHeader("content-disposition","attachment; filename = ForwardLoadHistory.pdf");
Response.ContentType =应用程序/pdf";
Response.WriteFile(Server.MapPath("ForwardLoadHistory.pdf"));//
Response.Flush();
Response.Close();
//System.Threading.Thread.Sleep(5000);
System.IO.File.Delete(Server.MapPath("ForwardLoadHistory.pdf"));
Response.End();
hi
try this one
Response.AppendHeader("content-disposition", "attachment; filename=ForwardLoadHistory.pdf");
Response.ContentType = "Application/pdf";
Response.WriteFile(Server.MapPath("ForwardLoadHistory.pdf"));//
Response.Flush();
Response.Close();
//System.Threading.Thread.Sleep(5000);
System.IO.File.Delete(Server.MapPath("ForwardLoadHistory.pdf"));
Response.End();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Vendors List.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
hw.Write("<center><h3>Vendors List</h3></center><br /><br /><br /><br />");
grdVendorList.AllowPaging = false;
grdVendorList.DataBind();
grdVendorList.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();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
这篇关于PDF下载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文