Web Printing Without Previewing
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:
- With the WebViewer, you can't send reports to the printer without displaying the Print dialog.
- The WebViewer control is available only in ActiveReports Professional Edition.
Printing with the Flash Viewer
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:
- using the StartPrint property
- using client scripts
StartPrint Property
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
Client Scripts
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
Printing to PDF
To print using PDF, add a WebViewer control to your web form and set its ViewerType property to AcrobatReader.
OnlyForPrint Property
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.