There are several variants of report print in the viewer. Each of them has its features, advantages and disadvantages.

 

Print to PDF

Print will be done using report export to PDF format. The advantages include excellent accuracy of location and report elements print in comparison with other print variants. The disadvantages include a set plug in the browser to view PDF files (modern browsers have an embedded tool for viewing and printing PDF files).

 

Print with Preview

A report will be printed in a separate pop-up browser to HTML format. A report can be previewed and sent it to the printer or copy to another place as a text or an HTML code. The disadvantages include cross browser capability when printing, a lack of need for setting special plug ins. A disadvantage is a relatively low accuracy of report elements location, due to features of HTML formatting implementation.  

 

Print without Preview

A report will be printed directly to the printer without preview. After you, select this menu item, the system print dialog is displayed. Therefore, as print in this mode is carried out in HTML format, print quality is similar to report print quality with preview.

 

Information

 

A report is printed using embedded methods of a used browser. That's why the presentation of the dialog window may differ in various operating systems and browsers. Also, a browser allow you to control print settings from the JavaScript code, so you should make required settings in the dialog window.

 

 

 

Settings

When selecting report print the menu with the selection of print variant on the viewer panel. The component has the ability to force set the required print mode. To do it you should set the printDestination property to one of the specified values below from the StiPrintDestination enumeration.

 

Name

Description

StiPrintDestination::Default

When selecting print the menu with available variants of print will be displayed (a value of a property by default)

StiPrintDestination::Pdf

Print to PDF format.

StiPrintDestination::Direct

Print to HTML format directly to the printer, the system print dialog will be displayed.

StiPrintDestination::WithPreview

Print to HTML format with preview in a pop-up window.

 

 

For example, you should set print mode only in PDF format.

 

viewer.php

 

<?php

$options = new \Stimulsoft\Viewer\StiViewerOptions();

$options->toolbar->printDestination = \Stimulsoft\Viewer\StiPrintDestination::Pdf;

?>

 

 

 

The viewer has an ability to fully disable report print, if it's not required. To do it you should set the false value for the ShowPrintButton property.

 

viewer.php

 

<?php

$options = new \Stimulsoft\Viewer\StiViewerOptions();

$options->toolbar->showPrintButton = false;

?>

 

 

 

Print events

If you need to make some actions before report print, you can use the onPrintReport event. In arguments of the event, the type of report print and a report will be transferred, sent to print.

 

viewer.php

 

<?php

$viewer = new \Stimulsoft\Viewer\StiViewer();

$viewer->onPrintReport = 'onPrintReport';

$viewer->renderHtml();

?>

 

function onPrintReport(args) {

var printAction = args.printAction;

var report = args.report;

}

 

 

 

To make the print work on the PHP server-side, you should add the invoke of the event handler on the client-side and define the onPrintReport event in the file of event handler with the same name on the server-side. You can find a detailed description of event work in the PHP Events Handler chapter.

 

viewer.php

 

<?php

$viewer = new \Stimulsoft\Viewer\StiViewer();

$viewer->onPrintReport = true;

$viewer->renderHtml();

?>

 

 

handler.php

 

$handler->onPrintReport = function ($args) {

$fileName = $args->fileName;

$printAction = $args->printAction;

 

return \Stimulsoft\StiResult::success();

};

 

 

 

You can find a detailed description of available argument values in the Viewer Events chapter.

 

 

Printing from a Code

There is an ability, which allows you to print a report from a code not using the viewer functions. You can find a detailed description of this functionality in the Printing Report from Code chapter.