我正在向我的页面发送PDF,并且我想在用户尝试保存PDF文档时设置默认名称。使用itextsharp将默认名称设置为PDF文档
我使用iTextSharp的和VB.Net
Using s As MemoryStream = New MemoryStream()
Dim Pdf_Writer As PdfWriter = PdfWriter.GetInstance(DocumentPDF, s)
DocumentPDF.Open()
DocumentPDF.SetMargins(10.0F, 10.0F, 10.0F, 10.0F)
DocumentPDF.Add(Table)
DocumentPDF.Close()
contentX= s.ToArray()
HttpContext.Current.Response.Buffer = False
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ContentType = "Application/pdf"
HttpContext.Current.Response.BinaryWrite(contentX)
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.End()
End Using
。
Response.AddHeader("content-disposition", @"attachment;filename=""MyFile.pdf""");
这种方式下载的文件(是的,它设置默认名称),但我只是想证明文件,如果用户想要保存它,好...保存(使用默认名称)
如何设置默认名称到我的PDF文档?
([在asp.net动态PDF指定文件名]的可能重复http://stackoverflow.com/questions/74019/specifying-filename-for-dynamic- PDF-在-ASP网) –