To economize your efforts each time a PDF document is printed, you can preset basic print options when exporting a report to a PDF format.
Note: The print preset properties are only available with the Professional Edition license. An evaluation message is displayed when used with the Standard Edition license.
In both Page/RDL and Section reports, you can set the PDF Print Preset properties using the Export dialog or through the code. The PDF print preset properties are available in the Export dialog of the following viewers.
Section Report
Visual Basic.NET code. Paste INSIDE the Form_Load event |
Copy Code
|
---|---|
Dim sectionReport As New GrapeCity.ActiveReports.SectionReport() Dim xtr As New System.Xml.XmlTextReader(Application.StartupPath + "\..\..\SectionReport1.rpx") sectionReport.LoadLayout(xtr) sectionReport.Run() 'Define settings for PDF Dim p As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport() p.Version = GrapeCity.ActiveReports.Export.Pdf.Section.PdfVersion.Pdf17 'Set default print settings using PrintPresets class p.PrintPresets.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None p.PrintPresets.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge p.PrintPresets.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two p.PrintPresets.PaperSourceByPageSize = True p.PrintPresets.PrintPageRange = "1-3" p.Export(sectionReport.Document, Application.StartupPath + "\PrintPresets.pdf") |
C# code. Paste INSIDE the Form_Load event |
Copy Code
|
---|---|
GrapeCity.ActiveReports.SectionReport sectionReport = new GrapeCity.ActiveReports.SectionReport(); System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath + @"\..\..\SectionReport1.rpx"); sectionReport.LoadLayout(xtr); sectionReport.Run(); //Define settings for PDF GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport p = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport(); p.Version = GrapeCity.ActiveReports.Export.Pdf.Section.PdfVersion.Pdf17; //Set default print settings using PrintPresets class p.PrintPresets.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None; p.PrintPresets.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge; p.PrintPresets.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two; p.PrintPresets.PaperSourceByPageSize = true; p.PrintPresets.PrintPageRange = "1-3"; p.Export(sectionReport.Document, Application.StartupPath + "\\PrintPresets.pdf"); |
Page/RDL Report
Visual Basic.NET code. Paste INSIDE the Form_Load event |
Copy Code
|
---|---|
'Set the rendering extension and render the report. Dim pdfExport = New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension() 'Define settings for PDF Dim pdfSettings As New GrapeCity.ActiveReports.Export.Pdf.Page.Settings() pdfSettings.Version = GrapeCity.ActiveReports.Export.Pdf.Page.PdfVersion.Pdf17 pdfSettings.PrintOnOpen = True 'Set default print settings using PrintPresets class Dim pdfPresetsSetting As New GrapeCity.ActiveReports.Export.Pdf.PrintPresets() pdfPresetsSetting.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None pdfPresetsSetting.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge pdfPresetsSetting.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two pdfPresetsSetting.PaperSourceByPageSize = True pdfPresetsSetting.PrintPageRange = "1-3" pdfSettings.PrintPresets = pdfPresetsSetting Dim outputFile = New IO.FileInfo("..\..\PrintPresets.pdf") Dim reportFile = New IO.FileInfo("..\..\PageReport1.rdlx") Dim fileStreamProvider = New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputFile.Directory, Path.GetFileNameWithoutExtension(outputFile.FullName)) Using pageDocument = New GrapeCity.ActiveReports.PageReport(reportFile).Document pageDocument.Render(pdfExport, fileStreamProvider, pdfSettings) End Using |
C# code. Paste INSIDE the Form_Load event |
Copy Code
|
---|---|
//Set the rendering extension and render the report. var pdfExport = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension(); //Define settings for PDF GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSettings = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings(); pdfSettings.Version = GrapeCity.ActiveReports.Export.Pdf.Page.PdfVersion.Pdf17; pdfSettings.PrintOnOpen = true; //Set default print settings using PrintPresets class GrapeCity.ActiveReports.Export.Pdf.PrintPresets pdfPresetsSetting = new GrapeCity.ActiveReports.Export.Pdf.PrintPresets(); pdfPresetsSetting.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None; pdfPresetsSetting.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge; pdfPresetsSetting.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two; pdfPresetsSetting.PaperSourceByPageSize = true; pdfPresetsSetting.PrintPageRange = "1-3"; pdfSettings.PrintPresets = pdfPresetsSetting; var outputFile = new System.IO.FileInfo(@"..\..\PrintPresets.pdf"); var reportFile = new System.IO.FileInfo(@"..\..\PageReport1.rdlx"); var fileStreamProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputFile.Directory, System.IO.Path.GetFileNameWithoutExtension(outputFile.FullName)); using (var pageDocument = new GrapeCity.ActiveReports.PageReport(reportFile).Document) { pageDocument.Render(pdfExport, fileStreamProvider, pdfSettings); } |