Workarounds: How to edit native Google Docs?

I found some pretty depressing QA's here that mentioned that Google Docs cannot be changed programmatically in the Google Drive API - there is a upload / download option.

I checked those similar threads:

1) How to programmatically manipulate google docs native files

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

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

Has anyone tried to run a google script application programmatically on the selected document, is this possible? Is it possible to run google app script programmatically with some parameters on input?

I just need to replace a few snippets of text in the native Google Doc`s, but I cannot use download-> modify-> upload (for example with word / html / pdf formats) as I would break the formatting of images, borders, etc. ... (client requirement: full Google integration without proprietary formats)

Do you have any innovative ideas or tips that would be useful to explore?

We are trying to use Google Drive as a very simple templating system (~ thousands of users, hundreds of Google Docs), but it seems like this is really the wrong idea as there are many restrictions along the way.

+2


source to share


2 answers


You cannot use the Drive API to programmatically control the content of a Google document, but you can use the document service in Script apps to perform text replacements and other edits:



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

+1


source


We are calling a google script application deployed on the same domain as the webapp, which changes the content of the documents before we load them into a proprietary format. We just replace a few lines with something complicated.

This solution works, but its a bit fragile (you need to install the app script + google app engine in the same domain), we don't know how quickly changes propagate after the script is run, so we always wait a small amount of time, for example 10 seconds before of how we will try to load the modified document.



An important disadvantage is that you cannot call GScript from localhost, so development is a bit slower as we have to upload our application to the google engine every time.

0


source







All Articles