【问题标题】:Save web page as Google Doc (or PDF) to Drive将网页另存为 Google Doc(或 PDF)到云端硬盘
【发布时间】:2016-04-26 03:56:21
【问题描述】:

有没有办法将网页保存到 Google 文档或云端硬盘中的 PDF?

使用:

var response = UrlFetchApp.fetch(url);
DriveApp.createFile(response.getBlob()).setName("fileName");

我已经能够获取 HTML 内容,并将其保存在 Drive 中的文件中,但它会保存包含 html 代码的文档,而不是解释的网页渲染。

有没有已知的方法可以做到这一点?

谢谢。

【问题讨论】:

    标签: google-apps-script save drive


    【解决方案1】:

    我在这个问题中找到了答案:Using HTML file to output a PDF

    按照我自己的开始,代码将是:

    var response = UrlFetchApp.fetch(url);
    var htmlBody = response.getContentText();
    var blob = Utilities.newBlob(htmlBody, 'text/html').getAs('application/pdf').setName('fileName.pdf');
    DriveApp.createFile(blob);
    

    谢谢,对双重问题表示歉意,真的很难找到。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多