I am trying to convert a website to a pdf using google apps script but for some reason the images in that webpage are not properly embedded into the output pdf.
For example purposes, say I am trying to convert the www.google.com to a pdf file using the following apps script.
function myFunction() {
var url = "https://www.google.com/" ;
// call the url using URLfetchApp
var response = UrlFetchApp.fetch(url);
var htmlBody = response.getContentText();
var blob = Utilities.newBlob(htmlBody, "text/html", "text.html")
var pdf = blob.getAs('application/pdf');
DriveApp.createFile(pdf).setName('googlePage.pdf');
}
The output pdf should be like :
But, the output I am getting is like :
which doesn't have the image and isn't also really pretty.