Creating a new document on google drive through the API

google-drive-api

Solution

The Google Drive API only deals with whole file operations. It has no understanding of the content of the files, including formatting.

You have two options:-

Use Apps Script (ie. not the Drive API) which has document manipulation features. See https://developers.google.com/apps-script/reference/document/

Create your templates in HTML (or Word, OpenOffice), then upload them to a new file, setting the option to 'convert to google docs'

Problem

Is it possible to create a new document (either using a template or completely dynamic) using the Google Drive APIs? I am working with a client that requires generation of word documents. I tired looking up but I couldn't find sufficient documentation on how to "create and format" documents using the APIs. For example, can I include the client's company logo on the top of the doc programmatically? I'd like whatever I am doing for this client to be generic (i.e including logo at the top etc) to be dynamic, so I can re-purpose this for other clients as well. I also am having difficulty finding documentation on any kind of formatting we could do on the documents (bold, italic, new paragraph) etc

Original source