Adding a Print Button to HTML ViewerType in ActiveReports 7
DESCRIPTION
The WebViewer control which is a part of the professional edition of ActiveReports, allow users to quickly display reports in web applications. It supports different types of ViewerType which are:
- HtmlViewer
- RawHTML
- AcrobatReader
- FlashViewer
However in this blog article our focus is on the HtmlViewer type which provides a scrollable view of a single page of the report at a time and downloads only HTML and JavaScript to the client browser. Some of our users have asked whether it is possible to add a Print button to the HtmlViewer toolbar? Well yes it is possible and here is how it will look like after addition to the toolbar:
IMPLEMENTATION
So let us now see how do we accomplish this task. The first thing which we need is to export the report displayed on the viewer using Custom HTML Outputter. So we will create a public class for the HTML outputter. The code required to go inside this class can be found here. Next in the Page_Load event we will use this class to export the report to HTML format and open the HTML in a new aspx page for printing. The Print will be initiated by sending a Print parameter to the aspx page. Here is the code:
Next, we will add a Print button to the HTML viewer toolbar and call the JavaScript print method to print the contents displayed in the aspx page. The script code will look like this:
So it's done. A sample application demonstrating this implementation can be downloaded using the link below: Download Sample