Return PDF from Published Apps Script Webapp

Viewed 128

I am new to apps script. I have a container bound script deployed as web app.

What I want to accomplish is call the web app url with some parameters which write values to a cell in the sheet. The other cell values are calculated based on supplied value.

When I call the url, the script should return PDF format of the sheet.

I found many examples where PDF file is saved to Drive and Link is returned. But I am not able to accomplish this seemingly simple task.

This is what I have tried But I get this error Exception: Converting from application/pdf to text/html is not supported. (line 4, file "Code")

function doGet(e) {

//Script part that writes value to cell
//...
//...
//...

  var response = UrlFetchApp.fetch('https://docs.google.com/spreadsheets/d/<sheet url>/export?format=pdf&gid=<sheet gid>');
  var blob = response.getBlob();
  return HtmlService.createHtmlOutput(blob);
}

0 Answers
Related