【问题标题】:Converting .docx to .pdf using Gotenberg and Google Cloud使用 Gotenberg 和 Google Cloud 将 .docx 转换为 .pdf
【发布时间】:2021-05-21 22:49:18
【问题描述】:

在这里,我偶然发现将 .docx 转换为 .pdf。唯一合理的解决方案似乎是Gotenberg,这是一个 Docker 驱动的无状态 API,Gotenberg js client 允许通过 JS 接口更轻松地与 Gotenberg 交互。

要使用 JS 客户端,我们需要定义 Gotenberg 的 Docker-powered 地址:

import { pipe, gotenberg, convert, html, please } from 'gotenberg-js-client'

const toPDF = pipe(
  gotenberg('http://localhost:3000'), <--- here
  convert,
  html,
  please
)

我既不是 JS 向导,也不是客户端或后端,所以我想问你们:我如何(如果可能)使用 Google Cloud 解决方案来实现它?

现在我正在使用 Firebase Cloud Functions 生成 .docx(与我在客户端所做的相同),并且我希望能够将它们转换为 .pdf(客户端和后端)。这是可以实现的吗?这是可扩展的吗?

【问题讨论】:

    标签: javascript node.js google-cloud-platform google-cloud-functions gotenberg


    【解决方案1】:

    您可以将Firebase Cloud Functions(使用底层云函数)与nodejs runtime 结合使用。但是,如果您不打算运行 Firebase 应用程序,我建议您只使用云函数。

    您可以查看this quickstart 以获得介绍。之后,您可以尝试部署自己的函数,在 package.json 文件中指定您的gotenberg-js-client 依赖项。

    您唯一需要决定的是函数将如何访问文件。我建议将 pdf 文件存储在 Cloud Storage 存储桶中,并使用 nodejs Cloud Storage client library 从您的 Cloud Function 中访问它们。

    【讨论】:

    • 为什么这个答案被标记为解决方案?它不包含任何有用的信息,也没有真正回答问题......
    猜你喜欢
    • 2019-02-18
    • 2015-10-14
    • 2017-08-17
    • 2018-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-15
    • 1970-01-01
    相关资源
    最近更新 更多