This example shows how to save a report template from the Stimulsoft Designer on the server side using PHP. First, include the Stimulsoft libraries:
<?php
require_once '../vendor/autoload.php';

use Stimulsoft\Designer\StiDesigner;
use Stimulsoft\Events\StiReportEventArgs;
use Stimulsoft\Report\StiReport;
use Stimulsoft\StiResult;
?>

Next, create a Designer object and configure JavaScript-related options:
$designer = new StiDesigner();
$designer->javascript->relativePath = '../';
$designer->javascript->appendHead('<link rel="shortcut icon" href="/../favicon.ico" type="image/x-icon">');

Define designer events before processing. You can assign a PHP function, the name of a JavaScript function, or a JavaScript function as a string. Multiple event handlers can be added using the append() method. In this example, the onSaveReport event is used to save the report template on the server:
$designer->onSaveReport = function (StiReportEventArgs $args) {
    $reportFileName = strlen($args->fileName) > 0 ? $args->fileName : 'Report.mrt';
    if (strlen($reportFileName) < 5 || substr($reportFileName, -4) !== '.mrt')
        $reportFileName .= '.mrt';

    $reportPath = "../reports/$reportFileName";
    $result = file_put_contents($reportPath, $args->getReportJson());

    if ($result === false)
        return StiResult::getError('An error occurred while saving the report file on the server side.');
    return StiResult::getSuccess("The report has been successfully saved to '$reportPath' file.");
};

Process the request on the server side using process():
$designer->process();

Create a Report object and load a report template. The loadFile() method does not load the report on the server side; it only generates JavaScript code for the client side:
$report = new StiReport();
$report->loadFile('../reports/SimpleList.mrt');

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

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

На скриншоте ниже Вы можете увидеть результат выполнения данного кода:

Saving a Report Template on the Server-Side

Используя этот сайт, вы соглашаетесь на использование файлов Cookie для аналитики и персонализированного контента. Файлы Cookie хранят полезную информацию на вашем компьютере, чтобы помочь нам повысить эффективность и удобство использования. Для получения дополнительной информации, пожалуйста, прочтите Конфиденциальность и Использование Cookie.