Print Without Viewing
In Windows Forms applications, you can print reports without previewing them using the Print method that is implemented as an extension method for the SectionDocument and PageDocument classes. Because it is an extension of the PrintExtension class, Print is not listed as a method on either of the document classes. You can find it in the GrapeCity.ActiveReports.Viewer.Win.v10 assembly under the GrapeCity.ActiveReports namespace. There are two ways to call this extended Print method. You can call it on the document object, or call it on the PrintExtension object and pass in the document. I've provided both ways in the code samples below, and commented out one of them. Also, you can see that one of them uses a Section report and the other uses a Page report.
Troubleshooting
If you see error messages like these, the tips below will help.
VB.NET
- 'Print' is not a member of 'PageDocument'.
- 'Print' is not a member of 'SectionDocument'.
- 'PrintExtension' is not declared. It may be inaccessible due to its protection level.
C#
- 'PageDocument' does not contain a definition for 'Print' and no extension method 'Print' accepting a first argument of type 'PageDocument' could be found (are you missing a using directive or an assembly reference?)
- 'SectionDocument' does not contain a definition for 'Print' and no extension method 'Print' accepting a first argument of type 'SectionDocument' could be found (are you missing a using directive or an assembly reference?)
- The name 'PrintExtension' does not exist in the current context.
Reference the Windows Viewer Assembly
To use the Print method, add a reference to the GrapeCity.ActiveReports.Viewer.Win.v10 assembly in your application.
Explicitly Import the Namespace
To enable the Print method, you also need to explicitly import the GrapeCity.ActiveReports namespace. Add code like the following at the beginning of the code file that calls the Print method.
Important: When you upgrade old ActiveReports projects, especially those created using ActiveReports version 6 or lower, the reference and code to import isn't added automatically with the ActiveReports 10 Upgrade tool. You can find more information on printing in Print Methods In ActiveReports.