【发布时间】:2018-04-23 22:46:36
【问题描述】:
我的要求是使用 Nodejs api 生成 UI(角度 4 应用程序)的 pdf 视图。为此,我从 UI 中获取了全部内容并进行了一些预处理,这些预处理将发送到 nodejs api。在节点 api 中,我使用 html-pdfpackage 从收到的 html 生成 pdf。能够生成具有正确样式的 pdf,因为它出现在 UI 中。以下是我的问题
- 将整个 UI 内容(html、样式、引导 css)传递给 Node api 的安全方法是什么。 (目前为 POC 目的作为普通字符串传递)
- 我将如何将
html-pdfpackage 生成的 pdf 流返回到 UI 以在新选项卡上显示它
来自 Angular 的节点 api 调用:
this.http.post('http://localhost:3000/api/createpdf', { 'arraybuff': data }, options)
.catch(this.handleError)
.subscribe(res => {
})
当前数据是普通的 html 字符串,我通过在节点中设置 body-parser 来检索它。
【问题讨论】:
标签: node.js angular api node-html-pdf