I want to convert HTML emails into a PDF. I have written the following piece of code.
var txt = msgs[i].getBody();
/* We need two blob conversions - one from text to HTML and the other from HTML to PDF */
var blob = Utilities.newBlob(txt, 'text/html',"Test PDF");
Logger.log(txt);
var tempDoc = DocsList.createFile(blob);
var pdf = tempDoc.getAs('application/pdf');
pdf.setName('Email As PDF');
DocsList.createFile(pdf);
The above piece of code first creates a Blob out of the HTML from a Gmail message and uses the getAs() function to convert it to a PDF. However, images in the HTML are not to be found in the PDF. Any ideas on how to get these images would be appreciated. Any alternative ideas on how to convert a gmail message to PDF is also welcome.