is it possible to build my own helper/handle Method and can i call this with an custom button from the Viewer?
I have modified the onEndExportReport function for testing to store the report as an export PDF Files to Server-side and it works fine, but i have to use the general Menu Button ( "save"-> "Adobe PDF File" ) to start the process.
My wish is to call the process from a single Button from toolbar.
Here is my code:
viewer.php
Code: Select all
<?php
require_once 'stimulsoft/helper.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Stimulsoft Reports.PHP - JS Report Viewer</title>
<!-- Report Office2013 style -->
<link href="css/stimulsoft.viewer.office2013.whiteteal.css" rel="stylesheet">
<!-- Stimusloft Reports.JS -->
<script src="scripts/stimulsoft.reports.js" type="text/javascript"></script>
<script src="scripts/stimulsoft.viewer.js" type="text/javascript"></script>
<?php StiHelper::initialize(); ?>
<script type="text/javascript">
var options = new Stimulsoft.Viewer.StiViewerOptions();
options.appearance.fullScreenMode = false;
options.toolbar.showSendEmailButton = true;
var viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false);
// Process SQL data source
viewer.onBeginProcessData = function (event, callback) {
<?php StiHelper::createHandler(); ?>
}
// Manage export settings on the server side
viewer.onBeginExportReport = function (args) {
<?php StiHelper::createHandler(); ?>
args.fileName = "Rechnung_<?php echo $_GET['id']; ?>";
}
// Process exported report file on the server side
viewer.onEndExportReport = function (event) {
event.preventDefault = false; // Prevent client default event handler (save the exported report as a file)
<?php StiHelper::createHandler(); ?>
}
// Send exported report to Email
viewer.onEmailReport = function (event) {
<?php StiHelper::createHandler(); ?>
}
// Load and show report
var report = new Stimulsoft.Report.StiReport();
report.loadFile("reports/Report.mrt");
report.dictionary.variables.getByName("param1").valueObject = "<?php echo $_GET['id']; ?>";
viewer.report = report;
viewer.renderHtml("viewerContent");
</script>
</head>
<body>
<div id="viewerContent"></div>
</body>
</html>
Code: Select all
$handler->onEndExportReport = function ($event) {
$format = $event->format; // Export format
$data = $event->data; // Base64 export data
$fileName = $event->fileName; // Report file name
$file= $fileName.".".strtolower($format);
$path2PDF=$_SERVER["DOCUMENT_ROOT"]."/stimulsoft/Libs/PHP/JS/pdf/";
if(strlen(trim($fileName))>0) {
$fp=fopen($path2PDF.$file, 'w+');
fwrite($fp,base64_decode($data));
fclose($fp);
}
//return StiResult::success();
return StiResult::success("Export OK! Message from server side. (".$path2PDF.$file.")");
//return StiResult::error("Export ERROR. Message from server side.");
};
Greetings
Dennis