我有一个PDF文件保存到下载文件夹中,但我想允许用户选择位置。这是我的代码。 我正在使用iTextSharp进行PDF创建。 它总是将PDF下载到下载文件夹,请帮助。
Document document = new Document(PageSize.A4, 0, 0, 15, 12);
PdfWriter writer = PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
pdfPage ab = new pdfPage();
PdfPTable table = new PdfPTable(4);
table.SetWidths(new int[] { 3, 1, 2, 3 });
table.SpacingBefore = 5f;
var blackListTextFont = FontFactory.GetFont("Arial", 8f, Color.BLACK);
phrase = new Phrase();
phrase.Add(new Chunk("", blackListTextFont));
cell = new PdfPCell(new Phrase(phrase));
cell.Padding = 5f;
cell.BackgroundColor = new Color(85, 142, 213);
cell.Colspan = 4;
table.AddCell(cell);
phrase = new Phrase();
phrase.Add(new Chunk("I", blackListTextFont));
cell = new PdfPCell(new Phrase(phrase));
cell.Padding = 5f;
cell.BackgroundColor = new Color(85, 142, 213);
cell.HorizontalAlignment = Element.ALIGN_CENTER;
table.AddCell(cell);
phrase = new Phrase();
phrase.Add(new Chunk("D", blackListTextFont));
cell = new PdfPCell(new Phrase(phrase));
cell.Padding = 5f;
cell.BackgroundColor = new Color(85, 142, 213);
cell.HorizontalAlignment = Element.ALIGN_CENTER;
table.AddCell(cell);
phrase = new Phrase();
phrase.Add(new Chunk("O", blackListTextFont));
cell = new PdfPCell(new Phrase(phrase));
cell.Padding = 5f;
cell.BackgroundColor = new Color(85, 142, 213);
cell.HorizontalAlignment = Element.ALIGN_CENTER;
table.AddCell(cell);
phrase = new Phrase();
phrase.Add(new Chunk("S", blackListTextFont));
cell = new PdfPCell(new Phrase(phrase));
cell.Padding = 5f;
cell.BackgroundColor = new Color(85, 142, 213);
cell.HorizontalAlignment = Element.ALIGN_CENTER;
table.AddCell(cell);
table.CompleteRow();
document.Add(table);
document.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename= SampleExport.pdf");
Response.End();
Connection.Close();