Page margins when printing from Viewer

Posted by: alexshakurin on 26 December 2022, 11:21 pm EST

    • Post Options:
    • Link

    Posted 26 December 2022, 11:21 pm EST

    Hello,

    I’ve encountered a problem while trying to print report from the WPF Viewer.

    The problem is that I can’t set custom margins for the document. Seems like AR ignores any margins I try to set. I tried SectionReport.PageSettings.Margins, SectionReport.Document.Printer.DefaultPageSettings.Margins and SectionReport.Document.PrintOptions.Margin.

    However, when I export this report to PDF and then print that PDF then final result differs - printed page has more margins.

    We have a paper with a logo and we want to make sure that content is positioned the same way regardless of how we print it (from the viewer or from the exported PDF).

    Can anyone help me with this?

    Thanks in advance!

  • Posted 27 December 2022, 8:42 pm EST

    Hi Alex,

    In order to assign PrintMargins to a report you will also need to set the PageScaling value in the PrintSettings class as the margins are not assigned when the PageScaling is set to None (see attached image).

    Refer to the code snippet below:

    report.Document.PrintOptions.Margin = new GrapeCity.ActiveReports.Extensibility.Printing.Margin(1, 1, 1, 1);
    report.Document.PrintOptions.PageScaling = GrapeCity.ActiveReports.Extensibility.Printing.PageScaling.FitToPrintableArea;

    Please find attached a sample implementing the same.

    >> However, when I export this report to PDF and then print that PDF then final result differs - printed page has more margins.

    This happens because when you print an exported PDF the print settings are set as per the default settings of your printer i.e. the default page size and default margins of your printer due to which the PDF print output may differ from the print output you get using the viewer.

    Regards,

    Anand

    PageSetupDialog(Image).zip

    TestWpfViewerPrintMargins.zip

  • Posted 1 January 2023, 6:07 pm EST

    Hello Anand,

    Your solution helped to resolve the issue.

    Thanks!

  • Posted 1 January 2023, 6:24 pm EST

    Hi Alex,

    We’re glad we were able to resolve your issue!

    Regards,

    Anand

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels