如何在MVC中按对话框保存pdf文件

时间:2016-02-06 17:03:13

标签: c# asp.net-mvc pdf savefiledialog

我想保存在用户想要的路径中生成的PDF文件,例如桌面或其他,我在同一页面中有2个按钮,第一个是生成报告,第二个是将报告保存为pdf,可以是一个人帮我怎么做like this box

 PdfPTable tablee = new PdfPTable(3);
            tablee.AddCell("ID");
            tablee.AddCell("AGE");
            tablee.AddCell("NAME");
            lenthee = db.persions.ToArray().Length;
            persion[] array = new persion[lenthee];
            array = db.persions.ToArray();
            for (int i = 0; i < lenthee; i++)
            {
                tablee.AddCell(array[i].ID.ToString());
                tablee.AddCell(array[i].age.ToString());
                tablee.AddCell(array[i].name.ToString());
            }

            Document doc = new Document(PageSize.A4, 1, 1, 1, 1);

            // here i want to ask the user where to he want to save the file (dialog box)then put the path in (path String attribute)
             String path = "C:\\Users\\se\\Desktop\\test.pdf";
            PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(path, FileMode.Create));
            doc.Open();
            Paragraph s = new Paragraph("report");
            doc.Add(s);
            doc.Add(tablee);
            doc.Close();

0 个答案:

没有答案