[]
The page demonstrates presetting basic print options when exporting a Section Report or a Page/RDLX report in PDF format.
type=note
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.
From the Visual Studio File menu, select New, then Project.
In the Create New Project dialog that appears, select any of the ActiveReports 19 templates and click Next.
Type a name for your project and click Create.
Select the type of report that you want to add and click Finish:
In the Design view, double-click the Form title bar to create the Form_Load event.
Add the following code to invoke the Export methods and set print presets in the Form_Load event.
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")
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");
'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
//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);
}