这是PDF的生成代码,和我追加的代码(但是这样,测试实际是不行的)
// Provide the page report you want to render.
GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new
System.IO.FileInfo(@"C:\Sample_PageReport.rdlx"));
GrapeCity.ActiveReports.Document.PageDocument reportDocument = new
GrapeCity.ActiveReports.Document.PageDocument(report);
// Create a output directory
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
outputDirectory.Create();
// Provide settings for your rendering output.
GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new
GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = pdfSetting;
//这是我追加的代码
//设置用纸尺寸为A5
reportDocument.Printer.PaperKind = PaperKind.A5;
//适应用纸尺寸
pdfSetting.SizeToFiT = true;
//Set the rendering extension and render the report.
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));
reportDocument.Render(pdfRenderingExtension, outputProvider, pdfSetting);
|