将PDF打印到Google云端硬盘中的文件夹

时间:2013-02-27 10:23:05

标签: javascript pdf printing google-apps-script google-drive-api

我正在使用脚本将电子表格打印到PDF。我想将其打印到驱动器上的某个位置" PDF文件夹"。有谁知道怎么做?

Heres是我的代码:

function printpdf(){
  var spreadsheet_id="0AkcI3cOVJXI3dHg3Nnk3Y2JUakViTkUzQzdXSUdLNEE";
  var spreadsheetFile = DocsList.getFileById(spreadsheet_id); 
  var blob = spreadsheetFile.getAs('application/pdf'); 
  DocsList.createFile(blob);
}

1 个答案:

答案 0 :(得分:0)

只需将其添加到文件夹中,如下所示:

(我重现整个代码)

function printpdf(){
  var spreadsheet_id="0AkcI3cOVJXI3dHg3Nnk3Y2JUakViTkUzQzdXSUdLNEE";
  var spreadsheetFile = DocsList.getFileById(spreadsheet_id); 
  var blob = spreadsheetFile.getAs('application/pdf'); 
  var folder = DocsList.getFolder('PDF Folder'); //get the folder by its path
  var pdf = DocsList.createFile(blob).addToFolder(folder);
}