How to programmatically manipulate native google doc files
Asked Answered
A

2

17

Is it possible to programmatically edit a native Google document, say to make certain words bold or hyperlinks? I know I can export that to some format like DOC or ODT, do the changes and put back. But tried this way manually and saw that I lost the exact look. Could not find any API or object model for native Google docs, although seems there is something for the spreadsheets.

Abernathy answered 20/7, 2012 at 11:3 Comment(0)
M
14

Unfortunately it is not possible to programmatically edit Google Documents (Google's Word Processor document) using a REST API. Only Google Spreadsheet offers such an API at the moment.

You could try Google Apps Script: https://developers.google.com/apps-script/ it is a hosted scripting environment and it offers a Google Documents Service that allows you to edit and manage existing Google Documents.

Lastly you could always upload a document using an open format such as RTF and have it converted to a native Google Documents using the Google Drive API.

Menu answered 21/7, 2012 at 1:37 Comment(3)
I tried apps-script - worked nicely. Combined with time driven trigger, I think I can have my requirement met. Thanks!Abernathy
Dear @Nivco, I can't find how I can upload a Word document using Google Drive API, and make it to convert to Google Doc format. Can you guide me please?Disqualification
Hi @SaeedNeamati, you can use the insert method from the Drive API, with the "convert" parameter in order to convert a Word document to a Google Docs format: developers.google.com/drive/v2/reference/files/insert - See also this SO postVernissage
N
0

As of November 2022, the accepted answer is obsolete as nowadays Google Documents as well other Google Drive file formats can be programmaticaly created and edited, but with some restrictions as not all the features available through the corresponding web app UI are programmatically available.

Landing page for developers of the available Google Drive file formats that have an API or Google Apps Script service:

The exepction is Drawings.

Service to automate the Google Drive files as well other Google Apps:

Nathanielnathanil answered 26/11, 2022 at 3:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.