Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to insert HTML text in Google docs?

How can I add/insert html text (contains italic/bold tag & some other tags for text formatting) in Google docs using Google Apps Script?

like image 508
exe Avatar asked Jul 05 '26 02:07

exe


1 Answers

You can use the in-built Utilities method to get the formatted text

function makeNewDoc() 
{ 
 var html = '<html><body><h1><i><b>HEADING</b></i></h1></body></html>';
 var blob1 = Utilities.newBlob("").setDataFromString(html, "UTF-8").setContentType("text/html");
 var newFileId = Drive.Files.insert({title: "TEST"}, blob1, {convert: true});
}
like image 69
Adharsha Neel Avatar answered Jul 08 '26 07:07

Adharsha Neel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!