pdf package

This commit is contained in:
2022-01-13 18:38:02 +01:00
parent 25106547e9
commit efbc2f3b2e
6 changed files with 251 additions and 43 deletions

View File

@@ -0,0 +1,30 @@
;(function () {
const r = context.request()
/** @type {import("../../..").HookException} */
const hEx = {}
if (r.query("pdf")) {
// pdf test
hEx.status = 200
hEx.bytes = context.pdf.fromHTML(
context.fs.readFile("testfiles/test.html"),
{
orientation: "Portrait",
pageSize: "A4",
title: "TestPDF",
marginTop: 30,
marginBottom: 30,
marginLeft: 30,
marginRight: 30,
headerLeft: "TestPDF",
headerCenter: "[date]",
headerRight: "[page] - [frompage] / [topage]",
headerSpacing: 10,
}
)
context.response.header("Content-Type", "application/pdf")
context.response.header("Content-Disposition", "inline; filename=\"mypdf.pdf\"")
throw hEx
}
})()