Skip to Content
avatar image
Former Member

How to add page setup and print layout option in crystal report viewer?

I am using crystal report in a WPF application designed in visual studio 2010. I have used two report viewers to display crystal report;

1: Microsoft.ReportViewer.WinForms

Code :

<Window x:Class="HelloWorld.MainWindow"
    xmlns:rv="clr- namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms"
        Title="WFReportViewer" Height="800" Width="900">
        <WindowsFormsHost Height="700" Name="windowsFormsHost1" Width="800">
            <rv:ReportViewer x:Name="_reportViewer" />

Output : [Post I run the above code, below is the output][1]


[When I click on page setup, I get this option ][2]


So, I can do page setup, view the changes, and can print the report then.

2: SAP CrystalReportsViewer

Code :

 <Window x:Class="HelloWorld.CrystalReportWindow"
            Title="CrystalReportWindow" Height="800" Width="900" Loaded="Window_Loaded">
        <Grid Name="grid1">
            <my:CrystalReportsViewer HorizontalAlignment="Left" Name="crystalRptVwr1" VerticalAlignment="Top" Height="700" Width="850" ShowOpenFileButton="False" ShowPrintButton="True" ShowExportButton="True" SnapsToDevicePixels="False" UseLayoutRounding="False" />

Output : [When I run this code, I get this output][3]


Now, an only print option is available here. there is no layout option or page setup option in crystal report viewer. I need to add them so that after we run crystal report, a user should be able to change page setup and check it's preview. I have searched on the internet a lot, but not able to find any solution. Can anyone please advice and help me on this?

Thanks in advance.

wfreport.png (18.8 kB)
wfpagesetup.png (77.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 22, 2018 at 01:17 PM

    Not many people use the WPF viewer so R&D has not spent a lot of time bringing it up to the abilities the WinForm viewer has.

    Due to the platform differences some things are not possible with that viewer.

    On the Download Wiki Page my printer test app will get all of the values CR saves in the RPT file:

    Printing Crystal Reports in .NET

    Using it as an example should get all of the properties you need. It's not the viewer generating the Print job, it's just some place to put a button to start the print job.


    Add comment
    10|10000 characters needed characters exceeded

  • Mar 19, 2018 at 02:14 PM

    Hi Adnan,

    Our Viewers need to send the print job from the viewer code and cannot hook into the WPF's print buttons.

    There is a way to hook into the Windows Form viewer, see this Post:

    If you go into the properties of the WPF viewer and click on the CR viewer in the Miscellaneous area you can turn on/off our various buttons. If you can figure out how to hook into our buttons in the WPF viewer you could replace our buttons with your own and do the coding behind it to print.

    Otherwise you don't want to use the standard WPF print buttons. Or possibly you could hide our Print button and do the CR Printer code using the PrintOutputController to do the printing.

    On the CR for download WIKI there is a printer test app that has all of the code in it to use.


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      First of all, thanks for giving your time and looking into this issue

      The suggestion of hiding crystal report viewer print button and adding a custom print button that will do the print job has been done by me. An issue with that is to find all printer settings (like margins, paper selection, orientation etc)and display a custom window from where a user can apply those settings and then view the changes. I am able to make a couple of those printer settings customization but not all.

      These all things I have to do since this crystal report viewer of WPF is not having page layout, print preview option, although the same was available in windows form's viewer.

      Can you please tell me why crystal report viewer designed for WPF is not having this option of page layout, as the same was available with windows forms?