2

I found few quite depressive QA here which mentioned that google documents cannot be modified programmatically in Google Drive API - there`s just upload/download option.

I checked those similar topics :

  1. How to programmatically manipulate native google doc files

  2. How do you create a document in Google Docs programmatically?

As I suppose we cannot download and upload directly native google doc formats. Is there any other way how to solve this requirement ?

Has anyone tried to trigger google app script programmatically on selected document, is that possible ? Is possible to start google app script programmatically with some parameters on the input ?

I just need to replace few pieces of text in native google doc`s but i cannot use download->modify->upload (e.g. with formats word/html/pdf) flow as i would broken formatting of pictures,borders etc... (customer requirement : full google integration no proprietary formats)

Do you have any innovative ideas or tips which would be good to explore ?

We are trying to use Google Drive as some kind of very simple templating system (~ thousands of users, hundreds of google documents) but it seems to be a really wrong idea as there is a lot of limitations on the way.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Martin V.
  • 3,560
  • 6
  • 31
  • 47

3 Answers3

0

You can't use the Drive API to programmatically manage the content of a Google Document but you can use the Document Service in Apps Script to perform text replacing and other editing:

https://developers.google.com/apps-script/service_document

Claudio Cherubino
  • 14,896
  • 1
  • 35
  • 42
  • and i suppose that standalone google app script in webapp can be triggered programatically. Thank you – Martin V. Dec 04 '12 at 23:40
  • 1
    you can deploy Apps Script as a web app that user can access: https://developers.google.com/apps-script/execution_web_apps – Claudio Cherubino Dec 05 '12 at 00:30
  • However you cannot call script from localhost (as you develop e.g. google engine app) because script can be accessed only from specific domain. We have full-featured google engine application and just because of missing option to edit google native documents we have to depend on remote google app script which runs in completly different environment. I hope that integration will be better in few years. – Martin V. Dec 05 '12 at 01:40
0

We invoke google app script deployed on the same domain as webapp which changes content of documents before we download them to proprietary format. We are just replacing few strings nothing complex.

This solution works but its a bit fragile (you have to install g app script + google app engine app in one domain), we are not sure how quickly are changes propagated after you trigger script so we wait always small amount of time e.g. 10 seconds before we try to download modified document.

Important disadvantage is that you cannot invoke GScript from localhost so development is a bit slower as we have to upload our app each time into google app engine.

Martin V.
  • 3,560
  • 6
  • 31
  • 47
0

Nowadays it's possible to use Java and other programming languages without having to use Google Apps Script by using the Google Docs API.

Also it is possible by using execute Google Apps Script code from other programming platforms by using Google Apps Script API, but it doesn't work with service accounts.

Notes:

There are some features available in the Google Docs user interface that aren't available in the Google Docs API.

Inserting content inside tables, that have rows and columns of different sizes might be complex due to the way that the indices work. Something that might help is to build the document from bottom to top.

Rubén
  • 34,714
  • 9
  • 70
  • 166