I am trying to write a script that will output a PDF with values that have been inputted into a form. On this PDF, I would like to include a logo at the top of the page, which is an image in a Google Drive folder.
Based on this question (and others), the image needs to be converted to base64 and then added to the HTML.
My issue is that even when I do this, the image still does not show up in the PDF file.
Here is my current code, just trying to output a PDF with the image, and nothing else
function htmlToPDF() {
var url = "https://drive.google.com/uc?export=view&id=1pHu-JPLA4Ml6R5Mc7pktLtqCAcGepLMG"
var img = UrlFetchApp.fetch(url)
var b64 = img.getBlob().getContentType() + ";base64," + Utilities.base64Encode(img.getBlob().getBytes());
var html_img = "<img src=\"data:" + b64 + "\" >";
var blob = Utilities.newBlob(html_img, "text/html", "text.html")
var pdf = blob.getAs("application/pdf");
DriveApp.getFolderById('1o-yYvlNmdRYsH-J6b31wrT2GYfkCQEGG').createFile(pdf).setName("text.pdf");
}
Here is what I get when I run this script
Thank you!