Google App Script - HTML to PDF to Email -- 2
Budget: $30 – $250 USD
We need to update this simple script as it stopped working. This was working fine until a few days ago.
function htmlToPDF() {
var html = "<h1>Hello world</h1>"
+ "<p>The quick brown fox jumped over the lazy dog";
var blob = Utilities.newBlob(html, "text/html", "text.html");
var pdf = blob.getAs("application/pdf");
DriveApp.createFile(pdf).setName("text.pdf");
MailApp.sendEmail("email", "PDF File", "",
{htmlBody: html, attachments: pdf});
}
This is now failing with the following error.
Exception: Conversion from text/html to application/pdf failed.
function htmlToPDF() {
var html = "<h1>Hello world</h1>"
+ "<p>The quick brown fox jumped over the lazy dog";
var blob = Utilities.newBlob(html, "text/html", "text.html");
var pdf = blob.getAs("application/pdf");
DriveApp.createFile(pdf).setName("text.pdf");
MailApp.sendEmail("email", "PDF File", "",
{htmlBody: html, attachments: pdf});
}
This is now failing with the following error.
Exception: Conversion from text/html to application/pdf failed.