This example shows how to display a report in the Stimulsoft Viewer for PHP with customized appearance and toolbar settings. First, you need to include the Stimulsoft libraries:
<?php
require_once '../vendor/autoload.php';

use Stimulsoft\Report\StiReport;
use Stimulsoft\Viewer\Enums\StiToolbarDisplayMode;
use Stimulsoft\Viewer\Enums\StiViewerTheme;
use Stimulsoft\Viewer\StiViewer;
?>

Next, create a Viewer object and configure JavaScript-related options, including the relative path to scripts and adding a favicon:
$viewer = new StiViewer();
$viewer->javascript->relativePath = '../';
$viewer->javascript->appendHead('<link rel="shortcut icon" href="/../favicon.ico" type="image/x-icon">');

Next, configure the viewer appearance and toolbar options. You can set full-screen mode, background color, theme, toolbar display mode, and control visibility of toolbar buttons:
$viewer->options->appearance->fullScreenMode = true;
$viewer->options->appearance->backgroundColor = 'black';
$viewer->options->appearance->theme = StiViewerTheme::Office2022BlackGreen;
$viewer->options->toolbar->displayMode = StiToolbarDisplayMode::Separated;
$viewer->options->toolbar->showFullScreenButton = false;

After configuring options, process the request on the server side using process():
$viewer->process();

Next, create a report object and load a report template. The loadFile() method generates JavaScript code to load the report on the client side:
$report = new StiReport();
$report->loadFile('../reports/SimpleList.mrt');

Assign the report to the viewer:
$viewer->report = $report;

Finally, render the viewer as a complete HTML page using printHtml():
$viewer->printHtml();

In the screenshot below you can see the result of the sample code:

Changing the Viewer Theme

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.