带有 phantom-pdf 配方的 jsreport:如何/在何处设置格式、边距、方向等基本设置...?

jsreport with phantom-pdf recipe: how / where to set basic settings like format, margin, orientation...?

我正在使用 jsreport(通过 npm)从 HTML 使用 phantom-pdf 配方渲染 pdf。

呈现是通过 HTTPS 调用启动的:

https://127.0.0.1/api/report

...post 数据是这样的字符串:

{ 
"template": {
    "content": /*...my HTML content template to render...*/,
    "recipe": "phantom-pdf",
    "engine": "handlebars" 
    },
"data": /*json string with data to pass to the template*/
}

我知道有 phantom-pdf 的基本设置(边距、格式、宽度、高度、方向、printDelay、waitForJS),但我不知道把它们放在哪里: - 在 HTML 模板中? - 在 jsreport 的 dev.conig.json 文件中? - 在单独的文件中?

...以及如何?

提前致谢!

您可以将这些设置作为 API 请求正文的一部分发送,在 template.phantom 属性.

{ 
  "template": {
    "content": /*...my HTML content template to render...*/,
    "recipe": "phantom-pdf",
    "engine": "handlebars",
    "phantom": { "margin": "5cm" }
  },
  "data": { "foo": "Hello" }
}