How to disable pdf file download option using JQuery? - javascript

How to disable pdf download using jquery or javascript.
In my website I am loading some pdf files in iframe. I need to protect my files.
So how can I dissable pdf file download, print those kind of options.
Please help me.
My website created using html. jquery, mysql and php

Since you are delivering pdf file directly into the browser, displayed using Adobe Reader ActiveX, how can it be possible to prevent file download, since the files are displayed after downloaded into your temp directory?
So it is not possible using ANY JavaScript library.
The only way to secure your master PDF files is by creating Images for each page and present those to the user on the web via your own interface (html, flash etc).
You may use ImageMagick along with GhostScript for this.
You may go through www.veryinteractivepeople.com/?p=521
Hope this helps...:)

Related

How to Prevent auto download (IDM) pdf file in view?

everybody. I have a question, I use pdf viewer and show pdf file. on my website
I showed pdf file. However, if on computer installs IDM, its will auto download file and can't show file. it will automatically download by idm.
I want to change my code which prevent auto
I searched a lot and didn't get an answer
download, but I don't know. Have you any idea?
How can I prevent a PDF file from being downloaded with JavaScript or html?
I am using PDF.js an
Thanks a lot!
here's my code.
File

Is there any way to display pdf files in browser such that the viewer can only read the file and can't save/download/print the file in any form

I have to integrate pdf files in my PHP web application such that the viewer of the file can not save/download/print the pdf file.
I am finding a way of doing this in any way like using javascript, jquery or straight in PHP or any other way if any.
I think you'd need a custom PDF viewer in your app, like what Google Drive does with images and documents.
I'm not aware of any functionality that allows an app to tell Chrome/Firefox or the registered PDF handler to limit user interaction like you mention.

Hope to create gmail attachment preview like functionality using angularjs

I have a requirement where I want to show the file preview to the users.
There are various file types which are supported like; .pdf, .xlsx, .doc, .rar, .jpeg, .png and many more.
When user clicks on the preview it should open the file in popup where preview of the file is shown to him. User can Zoom-in, Zoom-out, Download the file. Just as you can see into gmail for attachment preview.
Please, can anyone guide me to any relevant library or helpful resource for the same.
Thanks in advance
There are two main ways you can do this.
1) Server-side: Render previews once server-side (on file upload) into jpg/png images, and store the previews on the server. This is the easiest to implement on the client side, but requires extra storage on the server.
2) Client-side: Render the previews 'live' with javascript in browser, this reduces the amount the server has to do/store, but does require the client to fully download the file in-memory before it can render the preview, which for large files could be an issue. Also, you would need javascript libraries included for likely each individual file type, since most libraries will target one specific file format.
Server-Side is probably the recommended way to go. What are you using for your web server?
You are looking at creating document viewer.
Belive me its big work as browser does not understand these formats. Browser can render images directly on canvas but it does not know how to render the other files. So, any file other than image formats, one need to save them temporarily on server and then stream on the browser and show them using the respective file viewer.
You can convert doc and xlsx files to pdf and show these files using pdf viewer (http://ngmodules.org/modules/ng-pdfviewer). There are plenty of document converters available on internet (however you will need to check the licensing terms as most of them are GPL licensed, hense can not be used in commercial projects).
If you want to save this work then go for third party server those take all paint to convert documents in html5 such as https://crocodoc.com/why-crocodoc/
You can also try using google doc viewer google doc veiwer
This question is fairly broad. I'm not going through all the steps of how to implement an attachment viewer directive, but here are some pointers you might find useful.
To allow the user to download the file, you simply put a download link somewhere. If you are hosting the attachment on Amazon S3, Google Cloud Storage or some other cloud storage service, check their documentation. If you're downloading the files from your own server, make sure to set the Content-Disposition HTTP response header to attachment; filename="ORIGINAL_FILENAME", where ORIGINAL_FILENAME is the file name you want to user to see in the save dialog that appears when they click the download link.
Now on to the viewer.
For PDF files, I'd use pdfJS. There's an angular directive for it here.
You could look at something like CloudConvert for other files, to convert ehm to a PDF, and then displaying them in pdfJS, but then you probably want to store the PDF on your server as well, in addition to the original files, which requires extra storage. You might also be able to use the Google Docs viewer, or Office 365 viewer, as described in this answer.

Running JavaScript code on PDF pages on my domain?

I it possible to run javascript code on for example: mydomain.com/pdf/pdf-example.pdf?
Any ideas how to accomplish this?
My intention is to add live chat code so that we can help customers while they are looking at the PDF
You can use pdf.js to render a PDF file onto a standard HTML page. So instead of linking directly to the PDF file, you would create a new HTML page, where you would embed the pdf.js viewer, as well as any additional custom Javascript. Here is a demo. The downside to pdf.js, is browser support is limited.
Another option is pdfobject, which enables you to embed PDF's within pages. This uses the browsers native PDF viewer for rendering.

View file content of a file selected by a java script file uploader

In jQuery, I used file input type to upload a file. But now I want to show the content of that uploaded file on the browser without having any communication with the server side.
Is this possible and if so how to that.
You can try HTML5 File API:
Using the File API added to the DOM in HTML5, it's now possible for web content to ask the user to select local files, then read the contents of those files.
HTML5 File API is the answer to what to need. Here is a complete working example of what you want:
http://www.html5rocks.com/en/tutorials/file/dndfiles/

Categories

Resources