How to create a Google Doc through the Google API

5 views
Skip to first unread message

lowcoupling via StackOverflow

unread,
Nov 20, 2014, 4:34:15 AM11/20/14
to google-appengin...@googlegroups.com

I am developing a Google App Engine Python based Web application. I need to automatically create a new document in a folder in the Google Drive account of the currently logged user when he/she presses a button. I am trying to figure out what library to exploit. I am now using the Python Client Library 3.0 to manage the user's calendars but I can't see how to use them to create new docs and set up some initial content. It would be great if I could use some Javascript library but I am a bit confused about the many different (sometime depcreated) documentation I find on the Internet (i.e. Google Apps Script, Google DocsList, etc.).



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/27035972/how-to-create-a-google-doc-through-the-google-api

Uttam via StackOverflow

unread,
Nov 21, 2014, 12:14:31 AM11/21/14
to google-appengin...@googlegroups.com

You can try below code to create Google doc using Google App Script, you can add text, html content and images.

//Create document in google drive with given name, open the document and returns doc object
doc = DocumentApp.create('digest.doc');

//Get the document body
var body = doc.getBody();

//Insert some text into body
var text = body.editAsText();

text.insertText(0, 'This is sample text...\n');

You can refer this link for API documentation.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/27035972/how-to-create-a-google-doc-through-the-google-api/27054509#27054509
Reply all
Reply to author
Forward
0 new messages