1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-09-28 11:14:20 +02:00

Use pdfmake from globals.

This commit is contained in:
Bogdan Bodnar 2020-03-25 20:51:23 +01:00
parent 25ac6cf1e9
commit bded10211a
No known key found for this signature in database
GPG Key ID: 49E4169AD3CA42B0

View File

@ -5,22 +5,36 @@
* See /LICENSE for more information. * See /LICENSE for more information.
*/ */
import pdfMake from "pdfmake";
export function createAndDownloadPdf(SSID, password) { export function createAndDownloadPdf(SSID, password) {
const docDefinition = { const docDefinition = {
content: [ content: [
{ {
text: "Wi-Fi", style: "header", fontSize: 55, alignment: "center", text: "Wi-Fi",
style: "header",
fontSize: 55,
alignment: "center",
}, },
{ {
qr: toQRCodeContent(SSID, password), fit: "350", margin: [0, 80], alignment: "center", qr: toQRCodeContent(SSID, password),
fit: "350",
margin: [0, 80],
alignment: "center",
},
{
text: `SSID: ${SSID}`,
fontSize: 25,
alignment: "center",
},
{
text: `Password: ${password}`,
fontSize: 25,
alignment: "center",
}, },
{ text: `SSID: ${SSID}`, fontSize: 25, alignment: "center" },
{ text: `Password: ${password}`, fontSize: 25, alignment: "center" },
], ],
}; };
pdfMake.createPdf(docDefinition).download("wifi.pdf");
// pdfmake is exposed by reForis main application. Thus we can use it from globals.
window.pdfMake.createPdf(docDefinition).download("wifi.pdf");
} }
export function toQRCodeContent(SSID, password) { export function toQRCodeContent(SSID, password) {