Skip to content Skip to sidebar Skip to footer

Download Pdf From Google.script.run In Web App

What I'm trying to achieve is to download sheet as .PDF file from google script web app, but I have a problem: output file has (probably) wrong encoding (UTF-8 also doesn't work).

Solution 1:

When the blob of var blob = response.getBlob() is created as a PDF file using DriveApp.createFile(blob), if you can see the PDF completely, how about this modification?

From :

var blob = response.getBlob();
var charset = 'ISO-8859-1';
var str = blob.getDataAsString(charset);
return Utilities.base64Encode(str);

To :

var blob = response.getBlob();
return Utilities.base64Encode(blob.getBytes());

Reference :

If this was not the direct solution for your issue, I'm sorry.

Post a Comment for "Download Pdf From Google.script.run In Web App"