Reputation: 3792
I have a string str
containing html and I want to save it in an opened google doc format file in a way like this: doc.getBody().appendParagraph(str);
How can I convert that string in a doc format?
Upvotes: 2
Views: 1423
Reputation: 504
This worked fine for me
function html_to_doc()
{
var html = '<html><body><h1><i><b>HEADING</b></i></h1></body></html>';
var mediaData = Utilities.newBlob("").setDataFromString(html, "UTF-8").setContentType("text/html");
var resource = {
title: "Html_to_doc",
};
var optionalArgs = {
convert: true
};
var newFileId = Drive.Files.insert(resource, mediaData, optionalArgs);
}
Upvotes: 2