ppt to pdf或png with nodejs

发布于 2025-01-27 05:50:01 字数 1550 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怼怹恏 2025-02-03 05:50:01

您可以使用 aspose.slides.slides for node.js cloud sdk for node.js 将其转换为pdf,pdg,png,png ,还有许多其他格式a>。以下代码示例向您展示了如何使用aspose.spose.spose Cloud:

const cloud = require("asposeslidescloud")
const fs = require("fs")

const slidesApi = new cloud.SlidesApi("client_id", "client_secret")

const fileStream = fs.createReadStream("example.pptx")

// Convert the presentation to a PDF document.
slidesApi.convert(fileStream, "pdf").then((response) => {

    // Save the PDF document to a file.
    fs.writeFile("output.pdf", response.body, (error) => {
        if (error) throw error
    })
})

这是付费产品,将PowerPoint演示文稿转换为PDF文档,但是您可以每月进行150个免费的API调用以进行演示转换和其他目的。它提供了用于管理演示文稿的基于REST的API。我在Aspose担任支持开发人员。

You can use Aspose.Slides Cloud SDK for Node.js to convert presentations to PDF, PNG, and many other formats. The following code example shows you how to convert a PowerPoint presentation to a PDF document using Aspose.Slides Cloud:

const cloud = require("asposeslidescloud")
const fs = require("fs")

const slidesApi = new cloud.SlidesApi("client_id", "client_secret")

const fileStream = fs.createReadStream("example.pptx")

// Convert the presentation to a PDF document.
slidesApi.convert(fileStream, "pdf").then((response) => {

    // Save the PDF document to a file.
    fs.writeFile("output.pdf", response.body, (error) => {
        if (error) throw error
    })
})

This is a paid product, but you can make 150 free API calls per month for presentation conversions and other purposes. It provides a REST-based API for managing presentations. I work as a Support Developer at Aspose.

可是我不能没有你 2025-02-03 05:50:01

进行此类转换而不必使用付费云服务确实很棘手。因此,我创建了一个NPM软件包,该软件包允许进行此类转换等等: htttps:// https:// www.npmjs.com/package/file-converter-nodejs

await processor.convertFile({
  filePath: '/path/to/input.ppt',
  from: 'pptx',
  to: 'pdf',
  outdir: '/path/to/output',
});

注意,此工具要求您安装了libreoffice(对于某些特定的文件操作,PPT到PDF只需要Libreoffice)

请 必须安装这些依赖项,因此我创建了一个docker映像,该图像已经包含所有必需的依赖项: https://hub.docker.com/r/azertyha77/nodejs-python-soffice

如果您不知道从哪里开始,则可以查看这个简单的示例项目:

It is indeed quite tricky to do such conversions without having to use a paid cloud service. So I have created an npm package that allows for such conversions and much more: https://www.npmjs.com/package/file-converter-nodejs

await processor.convertFile({
  filePath: '/path/to/input.ppt',
  from: 'pptx',
  to: 'pdf',
  outdir: '/path/to/output',
});

Note that this tool requires that you have LibreOffice installed (and python for some specific file operations, ppt to pdf will only require libreOffice)

It might be a bit overwhelming to have to install these dependencies so I have created a docker image which already includes all required dependencies: https://hub.docker.com/r/azertyha77/nodejs-python-soffice

If you don't know where to start, you can have a look at this simple example project: https://gitlab.com/bouhelalhamza/file-converter/-/tree/master/example?ref_type=heads

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文