Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get google doc as HTML in google app script [duplicate]

How can I get google doc as HTML in google app script? For example. I can get document body like so.

DocumentApp.getActiveDocument().getBody();

But when I log it there is nothing.

like image 586
Ararat Harutyunyan Avatar asked Apr 28 '15 11:04

Ararat Harutyunyan


People also ask

How do I change a Google Doc to markdown?

If you want to enable Markdown support, open a document in Google Docs, head over to the top of the screen, go to “Tools” then “Preferences” and enable “Automatically detect Markdown.” After that, you're good to go.


1 Answers

function doc_to_html()
{
 var id = document_Id;
 var url = "https://docs.google.com/feeds/download/documents/export/Export?id="+id+"&exportFormat=html";
 var param = 
        {
          method      : "get",
          headers     : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
          muteHttpExceptions:true,
        };
 var html = UrlFetchApp.fetch(url,param).getContentText();
}
like image 126
Adharsha Neel Avatar answered Oct 14 '22 01:10

Adharsha Neel