Google Apps脚本将.docx文件转换为.pdf

发布于 2025-02-04 18:12:00 字数 518 浏览 1 评论 0原文

我正在制作Google Apps脚本“文档”加载项。

我有以下代码:

  return {
      name: DocumentApp.getActiveDocument().getAs('application/pdf').getName(),
      base64: Utilities.base64Encode(DocumentApp.getActiveDocument().getAs('application/pdf').getBytes())
    }

getActiveCument()方法禁止返回以下内容: 例外:该文档无法访问。请稍后再试。 [行:130,函数:getPDF,文件:代码] 这是因为Google Docs可以使用Google Doc文件,而不是.docx文件。

如何将文档中的.docx文件转换为.pdf文件?

注意:复制文件并删除上一个不是选项。

注意:我想在应用程序中(在代码中)进行。不手动:)

I am making a Google Apps Script 'Docs' add-in.

I have the following code:

  return {
      name: DocumentApp.getActiveDocument().getAs('application/pdf').getName(),
      base64: Utilities.base64Encode(DocumentApp.getActiveDocument().getAs('application/pdf').getBytes())
    }

The getActiveDocument() method is forbidden returning this:
Exception: The document is inaccessible. Please try again later. [line: 130, function: getPDF, file: Code]
This is because google docs works with google doc files and not .docx files.

How could I convert the .docx file I have in Docs to a .pdf file?

Note: copying the file and deleting the previous one is not an option.

Note: I want to do it within the app (in the code). Not manually :)

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

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

发布评论

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

评论(1

尹雨沫 2025-02-11 18:12:00

在MS Word 2013中打开您的DOCX文档。
在“文件”选项卡上进行2个单击,然后选择另存为。
3选择要保存文件的文件夹。在下拉菜单中另存为类型中,请选择PDF。单击“保存”按钮,您的DOCX文件将保存在PDF中。

Open your docx document in MS Word 2013.
2Click on the File tab and select Save as.
3Choose the folder where you want to save the file. In the drop-down menu Save as type, choose PDF. Click the Save button and your docx file will be saved in PDF.

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