你这是服务器导出包这个错误,还是本地导出出现这个问题。导出PDF可以参考这个代码
- // Provide the page report you want to render.
- System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\PageReport1.rdlx");
- GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);
- // Create an output directory.
- System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
- outputDirectory.Create();
- // Add attachment.
- var pdfSetting = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
- // using GrapeCity.ActiveReports.Export.Pdf;
- pdfSetting.Attachments.Add(new AttachmentInfo
- {
- Name = "file.txt",
- Content = System.IO.File.ReadAllBytes(@"D:\Reports\file.txt"),
- Description = "attachment description" // optional
- });
- // or
- //{
- // Name = "file.xml",
- // Content = File.ReadAllBytes(Application.StartupPath + "\\file.xml")
- //};
- GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
- GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
- outputProvider.OverwriteOutputFile = true;
- pageReport.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting);
复制代码
|