-
Notifications
You must be signed in to change notification settings - Fork 5
/
Showing a Report as PDF.html
49 lines (41 loc) · 1.65 KB
/
Showing a Report as PDF.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Showing a Report as PDF</title>
<!-- Stimulsoft Reports.JS -->
<script src="../scripts/stimulsoft.reports.js" type="text/javascript"></script>
</head>
<body>
Showing a Report as PDF
<br><br>
<script type="text/javascript">
// Create a new report instance
var report = new Stimulsoft.Report.StiReport();
// Load report from url
report.loadFile("../reports/SimpleList.mrt");
// Render report
report.renderAsync();
// Export report to PDF format and save to file
function saveReportPdf() {
// Export to PDF
report.exportDocumentAsync(function (pdfData) {
// Create blob data
var blob = new Blob([new Uint8Array(pdfData)], { type: "application/pdf" });
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
// Internet Explorer does not support the output of blob data, only save as PDF file
var fileName = report.reportAlias;
window.navigator.msSaveOrOpenBlob(blob, fileName + ".pdf");
} else {
// Show the new tab with the blob data
var fileURL = URL.createObjectURL(blob);
window.open(fileURL);
};
}, Stimulsoft.Report.StiExportFormat.Pdf);
}
</script>
<a href="#" onclick="saveReportPdf()">Show the PDF report (or save it, if blob is not supported)</a><br>
<br><br>
<div id="htmlContainer"></div>
</body>
</html>