I open MS-Word file in Google Document and edit it. But changes wasn't reflected to original MS-Word file. Please tell me how to fix this. Is there any way through API?
I really liked your question, see if this helps :
you need to edit the file using the following two options
Edit the file using Office Compatibility Mode (OCM)
Convert the file to Google Docs, Sheets, or Slides.
For using the Office Compatibility Mode (OCM), do the following
Go to :
https://chrome.google.com/webstore/category/apps
Go to the Extensions "Menu"
Search for --> Office
Install the " Office Editing for Docs, Sheets & Slides" extension
Now go to Google Drive, there go to the settings
and uncheck the Convert Upload option
(Convert uploaded files to Google Docs editor format)
However if the doc is heavily formated, this may not be
a good way to edit it.
Ref: See the link below
https://www.youtube.com/watch?v=odjJBYpJmxs
I am sorry i didn't see the last part of your question where you have asked for API. I have not done this before ...
however ever when i check in the web,,i didn;t see any API like Google Docs API, I can see the Google Sheets and Google Slides API though in the RESTful APIs that Google is providing.
So Maybe can redesigning you app a little using Google Picker of Google Drive API, may help OR use the paid Google Apps for work https://apps.google.com/products/docs/
Some one else , in this forum may reply with better answer.
Related
I have a google drive where am storing few google sheets. My java web application is able to search a file that is present in my own google drive using Javascript API. Is there a way to search for a specific files in other's google drive via code? i will be getting the shareable link to the google drive am supposed to search. can this be done? As far as i checked this is not possible. Also there is no where in google document that says i can search files in other's drive. Kindly someone confirm.
This is an OAuth question, not a GDrive question.
The account that the GDrive API will apply to is determined by the Access Token that it is called with. So, if you can get an Access Token for somebody else's Drive, then you can use that to search their drive. How you would get such a token will depend very much on the details of your use case and the trust relationship.
What I'd like to accomplish: Download a Google Docs doc (with Google Drive API), modify it (for example highlight some text), then store it back to Google Drive (not messing up the format, so that it can be edited in the Google Docs app).
(Preemptive research: I know that you can do some integration with Google's hosted AppScript, but I want to do this offline. I also know that a Google Docs doc can be exported to other formats, but I see no sign of reimporting in the Google Drive API.)
I'm not hopeful this can be done:
* The meta-data file (that you can get via the Google Drive API) lacks a "downloadUrl" attribute
* In offline mode, the data (stored in .../File System/) is binary and the Unix "file " command doesn't know what format it is.
Is this off-limits with the current Google Drive API?
Your best (only) approach is to export the doc to a format that you can edit locally (html, docs, etc) and then reimport it. HTML is of course the easiest, but also the most lossy.
I would like to build an application on a webpage, that does as google docs:
I want to build an app that allow people to work on a document in collaboration
I start with this: https://developers.google.com/drive/realtime/realtime-quickstart
But the problem is that it creates a file with the mimetype is "application/vnd.google-apps.drive-sdk".
I would like to work with google docs format, so people can open them with their google drive and edit their later.
The file created is not the proper format, and find it me impossible to open it.
( I try to edit the mimetype with "application/vnd.google-apps.document", however it creates the file in the google drive but it can't find the file when it try to load it).
How to create a google doc in realtime ? (If you can post the code here, it would help me a lot)
Then, it want to add the toolbar for editing(bold, italic,...).
After that, it would like to add the google picker to select the file to load.
I've got the current code to open a google spreadsheet
var spreadSheet = SpreadsheetApp.openById(docId);
Which works fine for converted google spreadsheets.
But how do I open an unconverted xls file using the google sheets app? (It defaults to using the google drive viewer when I do it like above mentioned)
Thanks
Going from another post which is asking a similar question I don't think it's currently possible. There's an open issue (issue 1019) requesting the ability to programmatically convert documents.
It's possible through Google App Scripts
https://code.google.com/p/google-apps-script-issues/issues/detail?id=1019#c15
Strange that Google Drive will allow other apps to be set as default for certain types of files. But won't let you set gsheets or doc itself as default for these file types.
Its kind of odd that a class Product innovator which includes awesome keyboard shortcuts for its products, will let you live with no option but to point checkbox, click on Open with and select its app to open.
There doesn't seem to be (to my knowledge) an API to edit Google Docs (not spreadsheets, their HTML based documents). Has anyone done something like the? Maybe by downloading the HTML version, editing and uploading the changes?
UPDATE (May 2019) The Google Docs API was officially launched in Feb 2019. The documentation is located at the link from my update in July below. A few weeks after launch, I produced a high-level video overview of what a mail merge application using the API would look like. (It's not a full-fledged G Suite Dev Show episode but does link to a working sample.)
UPDATE (Jul 2018) The Google Docs team pre-announced a forthcoming REST API at Google Cloud NEXT '18. Developers interested in getting into the early access program for the new API should register at https://developers.google.com/docs. The original answer below still stands as the REST API will become the second way you can access Google Docs programmatically.
Original answer (Mar 2017): (Most other answers are outdated.) Google Docs does not currently have a REST API, however developers can programmatically access (CRUD) documents using Google Apps Script, server-side JavaScript apps that are hosted at and run in Google's cloud. If you're new to Apps Script or to editing Google Docs with it, here are some learning resources:
Your first script which creates & edits a Doc, then uses Gmail to send it
to you.
I've got 4 intro videos for you (mostly Sheets-flavored)
They're in this playlist (see videos 5, 8, 22, 24)
Any forthcoming videos will be in this series
Useful pages in the official docs
How to CRUD Google Docs with Apps Script overview page
Extend Docs functionality by creating Docs add-ons via this quickstart
Apps Script reference documentation for Google Docs (Document Service)
See Google Docs add-ons that other developers have built
Simple example: if you have an existing Doc with a (Drive) file ID of DOCUMENT_ID_GOES_HERE, here's how you'd basically edit it with Apps Script, doing a pseudo "mail merge" of name & email into the document given placeholders {NAME} and {ADDR}:
function mergeNameEmail() {
// Open a document by ID
var doc = DocumentApp.openById(DOCUMENT_ID_GOES_HERE);
// Access the body of the document
var body = doc.getBody();
// Merge name & address from template
body.replaceText("{NAME}", "Ima Developer");
body.replaceText("{ADDR}", "123 Main St, Anytown, XX 00000");
}
The Document List API has been deprecated since September 2012 and looks like it could be retired after April 2015.
Updating the HTML version using the Drive API, as the question suggests, looks to be the only other way. I have been trying this and I have experienced a few of issues.
Comments are converted into citations and added to end of document.
If someone else is editing the doc via the browser any changes made by them between the API read and update time are lost.
Updates to a doc can break the formatting. For example I updated a doc several times and the vertical spacing between some elements (h1's, h2's etc) kept widening each time and ruined the doc.
When an API update occurs the cursor of anyone in the doc is moved to the top of the page.
There may be more issues. These are just the ones I have found in the last few days.
Not really sure if this is what you're looking for exactly but have you taken a look here http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html It looks like it allows editing for content (v3.0 anyway).
There is com.google.api.services.drive.model.File.getExportLinks
You can get a Google Doc as a docx (for example), edit it using your favourite docx editor, then upload again. See the samples for doing this (starting with GoogleDriveDownloadAsDocx) in the context of docx4j. Note the README.
Or do the same with any of the other export formats.
(2019) Google now provides API for docs, slides, sheets, drive.
There is a sample app for this, Dr. Edit, on Google Drive's documentation.