pdf package
This commit is contained in:
30
demo-api/hooks/mycol/get_return.js
Normal file
30
demo-api/hooks/mycol/get_return.js
Normal 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
|
||||
}
|
||||
})()
|
||||
Reference in New Issue
Block a user