Pro Edition You can print a report from a web application without making your users preview it when you use the WebViewer in ActiveReports Professional Edition. In this article, I'll show you a couple of ways to print a report directly to the client printer. Important considerations:
To use the Flash viewer, add a WebViewer control to your web form and set its ViewerType property to FlashViewer. There are two ways to print a report using the Flash viewer:
Expand the FlashViewerOptions, then the PrintOptions, and set theStartPrint property to True. This displays the system Print dialog when the Flash viewer loads in the browser so you can print the report without previewing it. For more details, see the following topics in the User Guide: Flash Viewer | Provide One-Touch Printing in the WebViewer (Professional) | ActiveReports Web Pro
In the source view of your web form, add JavaScript like the following to create an event handler for the OnLoadProgress event. You can use the State property to detect when the report finishes loading and use the Print method to display the system Print dialog, allowing you to print the report without previewing it.
//javascript
viewer.setEventsHandler({
OnLoadProgress: function(e) {
if (e.State == "Completed") {
// Set printing options
var ops = viewer.CreatePrintOptions();
// Modify paper orientation
ops.AdjustPaperOrientation = "Auto";
// Modify page scaling
ops.ScalePages = "Auto";
// Clear page range settings
ops.ClearPageRanges();
// Set page range
ops.AddPageRange(1, e.PageCount);
// Start printing
viewer.Print(ops);
}
}
})
For more information, see the following topics in our User Guide: ActiveReports Web Pro | Customizing the Flash Viewer UI
To print using PDF, add a WebViewer control to your web form and set its ViewerType property to AcrobatReader.
Expand the PdfExportOptions and set the OnlyForPrint property to True. This displays the Adobe Acrobat Reader Print dialog when the viewer loads in the browser so you can print the report without viewing it in the Acrobat Reader. Important: When generating a PDF with a password using the Encrypt property, the OnlyForPrint property setting is invalid.