-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.html
46 lines (31 loc) · 1.25 KB
/
report.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
<html>
<head>
<script src="./postoptions_report.js"></script>
</head>
<body>
<button type="button" onclick="downloadreport()">Download Report</button>
<script>
// Does a POST Request with options in postoptions_report.js to get the PDF from URL: https://jsreport-server-eadvisorapp.azurewebsites.net/api/HttpTrigger1/
function downloadreport() {
fetch("https://jsreport-server-eadvisorapp.azurewebsites.net/api/HttpTrigger1/", {
body: JSON.stringify(postoptions_report),
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8',
"Access-Control-Allow-Origin": "*"
},
})
.then(response => response.blob())
.then(response => {
const blob = new Blob([response], { type: 'application/pdf' });
const downloadUrl = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = downloadUrl;
a.download = "file.pdf";
document.body.appendChild(a);
a.click();
})
}
</script>
</body>
</html>