Search code examples
securitydocumentationviewer

Google doc viewer display private documents or python doc rendering library


I have a website which in a section gives users access to some documents. The documents cannot be downloaded from the site, but only if the users are logged in.

Is is possible to use google docs viewer to show a preview of the documents to the user, considering the documents are not downloadable if you aren't logged in ... will the viewer be able to download them in order to render them? As an optional feature, could it use a secure connection when showing the documents?

If this is not possible with google docs viewer, do you know some python library that could render documents as HTML (so that I can return them to the user)? The documents will probably be of various types (like docs, excels, pdf, ppts, etc).


Solution

  • It's not possible with Google's doc viewer since it needs the URL of the file to be displayed as a parameter (which makes it possible to retrieve the URL and download the documents without being logged in), if want to use it anyway, you'll have to create a preview version of your documents.

    Edit :
    You can change the url parameter of Google's doc viewer to a script on your server, this script should only accept requests to documents from Google's doc viewer ( identifiable with the user agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0,gzip(gfe) (via docs.google.com/viewer) it's light, I know ) and serve the appropriate file depending on an id parameter or something. This way you can control who gets access to the documents. That's my 2 cents.