0

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.).

Nick
  • 3,581
  • 1
  • 14
  • 36
lowcoupling
  • 2,151
  • 6
  • 35
  • 53
  • 1
    http://stackoverflow.com/questions/2704902/how-do-you-create-a-document-in-google-docs-programmatically – K K Nov 20 '14 at 09:33
  • the Google Documents List Api 3.0 (proposed in the answer of the question you have posted) are deprecated since 2012. – lowcoupling Nov 20 '14 at 09:37
  • You can refer this https://developers.google.com/drive/web/integrate-create . But you will need a Drive UI. Although not sure how to do that but still this can be helpful – K K Nov 20 '14 at 09:42
  • Thank you but it does not explain anything to me. I still can't find any reference about how to create a brand new document in Google Docs (Drive or whatever), with some custom sections in it – lowcoupling Nov 20 '14 at 09:44
  • I found this example page: https://developers.google.com/drive/v2/reference/files/insert#examples . You can create a doc just the way you want. Still no documentation! – K K Nov 20 '14 at 09:49

1 Answers1

1

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.

Purushotham
  • 3,770
  • 29
  • 41