Google Apps脚本:用于将文本文档转换为PDF的代码? [英] Google Apps Script: code to convert a text document in PDF?
问题描述
我想要一段代码来将Google docs文本文档模板转换为PDF文件.我知道如何将新文档创建为Google文本文档,但不知道如何将其转换为PDF文件.我找到了这段代码:
I'd like a snipe of code to convert a google docs text document template in a PDF file. I know how to create a new document as a google text document, but not how to transform it in a PDF file. I find this piece of code:
var pdf = UrlFetchApp.fetch("https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key="+key+"&exportFormat=pdf&gid=1&gridlines=0&printtitle=0&size=7&fzr=true&portrait=1&fitw=1", requestData).getBlob().setName(name);
return pdf;
但是我不需要电子表格自定义(实际上,我不需要电子表格,而是文本文件).
But I don't need spreadsheet customization (actually, I don't need spreadsheet, but text file).
我该怎么办?仅使用 UrlFetchApp.fetch
类?
How can I can do it? Only with UrlFetchApp.fetch
class?
另一个问题:创建后可以自动发送要打印的PDF文件吗?
One more question: can I automaticaly send this PDF file to be printed after I've created it?
谢谢!
推荐答案
如果我对您的理解正确,那么您的问题是将文本文档转换为pdf吗?
If I understand you correctly your question is about getting a text document as pdf ?
有一个专用的方法:
DocsList.getFileById('document ID').getAs('application/pdf');
请参见与相关文档在这里
这篇关于Google Apps脚本:用于将文本文档转换为PDF的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!