Google Apps脚本将.docx文件转换为.pdf
我正在制作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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在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.