Developers / Export Reports / Set PDF Print Presets
Set PDF Print Presets

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

    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/RDLX 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);
    }
    
See Also

Report Readers