PHP Pdf export

Stimulsoft Reports.PHP discussion
Post Reply
taylor
Posts: 1
Joined: Thu Feb 06, 2025 8:53 am

PHP Pdf export

Post by taylor »

Hello, how can I convert the pdf export in export.php to API? My goal is to trigger the API and save the pdf file in a folder. Thank you.

EXPORT.PHP


<?php
require_once 'vendor/autoload.php';

use Stimulsoft\Enums\StiHtmlMode;
use Stimulsoft\Export\Enums\StiExportFormat;
use Stimulsoft\Report\StiReport;


$report = new StiReport();

$report->process();

$report->loadFile('reports/Yemek_Listesi.mrt');

$report->render();
?>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<title>Exporting a Report from Code</title>
<style>
html, body {
font-family: sans-serif;
}
</style>

<?php
$report->javascript->renderHtml();
?>

<script type="text/javascript">

function exportToPdf() {
<?php
$report->exportDocument(StiExportFormat::Pdf);
echo $report->getHtml(StiHtmlMode::Scripts);
?>
}

function exportToExcel() {
<?php
$report->exportDocument(StiExportFormat::Excel);
echo $report->getHtml(StiHtmlMode::Scripts);
?>
}

function exportToHtml() {
<?php
$report->exportDocument(StiExportFormat::Html);
echo $report->getHtml(StiHtmlMode::Scripts);
?>
}
</script>
</head>
<body>
<h2>Exporting a Report from Code</h2>
<hr>
<button onclick="exportToPdf();">Export Report to PDF</button>
<br><br>
<button onclick="exportToExcel();">Export Report to Excel</button>
<br><br>
<button onclick="exportToHtml();">Export Report to HTML</button>
</body>
</html>
Lech Kulikowski
Posts: 7284
Joined: Tue Mar 20, 2018 5:34 am

Re: PHP Pdf export

Post by Lech Kulikowski »

Post Reply