Grab document text from Google Drive public document and display on Website - google-drive-api

I just had an idea to have a collaboratively worked-on public Google Drive document's contents displayed on my Web site. I was hoping this would be straightforward, as I am only going to extract simple text and the document is public, so no authentication shenanigans will bar my way.
I have looked at Google Drive REST API, but turns out I can only get file metadata and/or the entire document file. Not just the document content.
I do not wish to spend a day coding to do this, I thought it would be nice to have, but can live with just linking into the file directly from my Web site. Anyone tried this before? Anyone experimented with Google Drive API and has a feel for how much work would be involved?

If you are thinking of getting the content of a native Google document (like a Google spreadsheet or a Google doc), this is currently possible with the Drive API.
In the Drive API, for Google native document types you will have a series of 'exportLinks' as part of the metadata of the file. Each of these export URLs allow you to download the content of the Google document in a specific export format (like RTF, plain text, HTML, PDF etc...). Updating my answer...
See the documentation for this: https://developers.google.com/drive/manage-downloads#downloading_google_documents

Related

Can downloading a public file from Google Drive reveal the owner's identity?

I have a document in my Google drive, which I want somebody else to download from a Google Sites website I have created. But I don't want the person viewing the document to know my identity, and I don't want to be able to know the identity of anybody viewing the document. This is because the document is part of a paper submission to an academic conference, where the reviewers will be downloading and viewing this document, and the conference requires strict anonymity between the authors and the reviewers.
I have created a public link to the document on my Google Sites webpage, so that anybody who visits the webpage can download the file. And I have tried logging out of my Google account, and downloading the file, which shows no sign of my name. But I would just like to double check that if anybody downloads this file, they will definitely not be able to know my identity (e.g. my Google account name). I know that there may be ways to find out the document's author by looking in the meta-data, but I have been careful with this already. I am specifically interested to know if there is any loss of anonymity by sharing the link through Google Drive.
Here are the specific steps I took to make the document available for download:
Created a Google Sites webpage
Created a document called "test_document.pdf"
Uploaded this document to my Google Drive
In Google Drive, after clicking on this document, I did Share->Get Link->Anyone on the internet with this link can view->Copy link.
In my Google Sites webpage, I create text saying "Download document here"
After highlighting this text, I clicked on "Insert link".
I then pasted the link from before.
When viewing the webpage, you can then click on the "Download document here" text, and it downloads the document, and saves is as file "test_document.pdf".
I have found the answer myself, which is Yes, downloading a document from Google Drive can reveal the document's owner. If you open the document within the Google Drive environment, and then click on the three buttons, then click on Details, it reveals who the owner is. If you just download the file without inspecting the details within Google Drive, then it doesn't reveal the owner, but I don't know how to force a direct download without allowing somebody to open the file within Google Drive.

How to view Google drive HTML as pdf in google drive

I would like to share pdf in google drive but even with featurs of preventing downloading and printing still can download it image by image that's why i thought to use another way after some research I found pdf2htmlEX so after i convert my pdf to html I upload it in google drive but when i wanted to opended it's appear as html code not as pdf
any help to solve that issue and any idea to share pdf without be downloadble image by image
It sounds like you're trying to secure your PDF and keep people from downloading/screenshotting its contents. Unfortunately, even if you successfully convert the PDF to HTML, people will still be able to view and therefore download/screenshot the contents. It's hard to prevent piracy.
As for the issue regarding your HTML files displaying as HTML in Google Drive, Google Drive doesn't support this. Google Drive no longer renders HTML files as of August 31, 2015:
https://gsuiteupdates.googleblog.com/2015/08/deprecating-web-hosting-support-in.html
If you're looking for a way to secure your PDF, most people will tell you that the simple answer is: you can't. Tools exist that help prevent screen recording and screen printing, but they're expensive and not foolproof. Someone can also just take a picture of their screen. The reality is that if you want to share content with the world through a PDF, you have to accept that it might be shared or stolen.
If you just want some basic protection through Google Drive, Google offers some advice for preventing copying and downloading:
To prevent commenters and viewers from downloading, printing, or
copying your file:
Click Share or Share Add people.
In the bottom right, click Advanced.
Check the box next to "Disable options to download, print,
and copy for commenters and viewers."
Click Save changes.
Click Done.
Source

How to generate an HTML view in App Script from a Google Sheet

I have a client that uses Google forms to take orders and wants to be able to turn the resulting Sheet into a document of Packing Slips. Being a python person I am currently taking her .tsv and making nice HTML printable docs but want to be able to make a plug-in for her so that on any Sheet of this type she can click "Make Packing Slips" and it either opens a new tab with generated HTML (I'm ok using googles templating) or maybe even convert the HTML into a PDF and save it to her drive? Either way I'd rather design the document all in HTML and CSS rather than trying to make a google doc if at all possible. Is the feasible? Any starting points? Thanks!
You need to learn about Google App Script => https://developers.google.com/apps-script/overview
Then these Links should suffice
HTML Service: Create and Serve HTML
Google Container-bound Scripts for Google App Script (Can not post link for this due to low reputation)

Google Docs Viewer for rendering HTML

I'm using Google Docs Viewer (https://docs.google.com/viewer) to display the contents of documents in my app. I support many different types of document (e.g. PDF, Microsoft Word, Plain Text, HTML, etc.). Everything works well except for HTML. Google Docs Viewer treats HTML as text and displays the source.
Is there any way to get Google Docs Viewer to render the HTML?
Here's an example:
https://docs.google.com/viewer?url=http%3A%2F%2Fwww.google.com&embedded=true
Instead of rendering the Google home page, it shows the HTML mark-up.
I'm hoping I can use the Google Docs Viewer for all types of documents and not have to treat HTML differently.
Imagine an attacker uploads an HTML file of google's sign page
Makes the html public and sends it over the email to your gf with the subject
Flash Fashion Sale Discount Coupons
Your gf will obvious click the link and won't be surprised to see Fake google sign in page on a docs.google.com domain .
She will convincingly enter her real credentials and will be redirected to attacker's server and then some real google docs page to remove suspicion.
So to prevent users from phishing attacks google stopped rendering HTMLS
source

Can I use Google Drive's editor interface embed in a website?

I want to use google drive to store the files, but allow the users of my website to be able to edit them transparently, so that they don't have to go to google drive's website.
Is this possible with the current API? Thus far I have only seen how to create an app for them to install in google drive, or doing something like DrEdit (https://developers.google.com/drive/examples/), which parses the files to JSON and uses the ACE editor, which is definitely not what I want.
EDIT:
I believe it is not possible to do this with Google Drive, I've decided to go with Zoho Docs instead.
Yes it's possible. The biggest consideration is how much formatting you want to support. Eg. if it's plain text, it's very simple. If you want to support character or layout formatting, it becomes more complex.
I don't believe its possible to embed the editor (or even embed a preview!) using an iframe, because if you look at how the google docs page loads, it first redirects you to the login page, and that automatically logs you in if you are already logged in, and redirects you back to the docs editor.
This means that the iframe would have to at least pass through the login page, even if the user doesn't need to enter anything. However, google's login page has the x-frame-option header set to SAMEORIGIN (or deny?), and thus, the browser refuses to display it, and thus you can't actually get logged in!
The only way I've found to enable just preview embedding (not editing), is to publish the document first (via the File->publish to web menu item).