Google Drive SDK: convert MSWORD to PDF - ExportLinks NULL - google-drive-api

When I have a File in Google Drive that is a native Google Docs document, then I have access to exportLinks for different mime-types, also for PDF;
But I have MSWORD documents that have been generated. The exportLinks property is always null for MSWORD document. In the web interface I can print which downloads a perfectly converted PDF document.
Question: can I generate a PDF from a MSWORD file somehow using the SDK ?
Been up and down through the docs looking for clues.
The download/print link downloads from a real long URI :
https://doc-0o-a0-docsviewer.googleusercontent.com/viewer/securedownload/1ve0rd17der7n5d32lker62ffdq2175h/<randomstring>/<longnumber>/<randomstring>=/<randomstring>/<randomstring>==?docid=<randomstring>&chan=<randomstring>&dom=<googleappsdomain>&sec=<randomstring>&a=gp&filename=<filename>&nonce=<nonce>&user=<userid>&hash=<hasvalue>
anybody ?
Thx

ExportLinks are only provided for documents in Google-native formats, so you'll have to convert the MS Word document to Google Docs before you can export it as pdf (and other supported file formats).

Related

Generate a google doc via Java

I've been swimming through searches and tutorials and guides and references for days, and I can't seem to find a good way to generate google docs via Java.
I can generate/import .txt files as regular google doc files successfully with java using the drive api, but that's only text files; I need to at least include unordered lists and links in the doc for it to be useful.
My next attempt would be to generate a .rtf or a .doc and then try to import that into google docs, but before I embark on such a project, I wanted to ask you guys first. I also see the realtime api, but it looks like it doesn't specifically deal with docs, just arbitrary data.
What's the recommended way to upload a new google doc with lists and links and stuff?
Thanks!
Probably the simplest import format would be HTML. Just set convert=true and you should be good to go.
There is no stand-alone API for creating or manipulating the contents of Google Docs files. As you've found, you can create documents in other formats and import them with the Drive API.
If you don't need to work in Java, the other option is to use Google Apps Script, which provides a service for creating and manipulating Google Docs files. More information in this guide.

Convert word document to Google drive document

Im building an application in nodejs that uploads documents to google drive, how can i convert the document to google docs format before uploading it or while uploading it.
You want to specify convert = true when doing the insert. See https://developers.google.com/drive/v2/reference/files/insert

Generating a PDF using Google Docs API

Is it possible to provide HTML for the Google Docs API and have it output as a PDF? As far as I can tell, it seems like it is possible to submit an HTML document to Google Docs, and then have Google Docs convert it to a PDF.
I'm checking the API documentation and it has a lot of information about dealing with PDFs already created, but I'm not seeing anything about creating them.
Also, does it accept CSS styling as well, or is it pure HTML?
Yes, it is, with two requests. You can import the file as a Google Docs, then export it to PDF. Using the Drive API.
https://developers.google.com/drive/v2/reference/files/insert https://developers.google.com/drive/v2/reference/files/get
this is what your saying right?

embedLink in Google drive's file resource

When I get a file's metadata using Google drive REST API, there is no field like embedLink in file's resource. While in documentation of file resource it is mentioned that this field is meant for embeddable link. How do I get this field in my file's resource?
Thanks in advance.
Only files with known mime types contain an embedLink such as Docs files and files that can be previewed with Drive's Preview app.

Get google drive file download URL

Following the Hello world application and using the File Picker, I am able to get a google drive file information.
I would like to get the download url of this file (it is a binary file) in a my web application.
Is there any way to get it with the new javascript sdk?
Yes.
The Picker returns the id string. Use this to get the item object (https://developers.google.com/drive/v2/reference/files/get) which will contain a variety of download URL's depending on your precise requirement.