print and download protected pdf viewer for web - javascript

i want to add viewer to web site.
the basic idea of the pdf viewer is show uploaded pdf files in the server to the client.
user cant print or download document.as a example for this kind of pdf viewer is slideshare.
it has no default option for download(slideshare people provide their custom button for do that)
Only users can be able to view document.
I tried several PHP,JavaScript plugins for doing that but unable to find one that has no print and downloadable options.

Printing option is a built in browser option so you can't restrict it by any kind of plugins or scripts.

You can Render the page empty in case of printing using CSS
#media print { .no-print {display: none; }}
and you should try to find an option to stop the control that views your PDFs from printing

Basically, you have the Flash and Javascript solutions. While Flash technology is safer, it looks a bit obsolete and is avoided by some developers. Javascript, being a client-side technology, can only obfuscate the actual URL of the document or document content (pdf file).
For the Javascript side, the pdf.js viewer is quite popular.

Related

preventing user from saving file from website but allow him to print it

I am working with a client who has a business of selling a genre of PDF files online and so he wants a functionality for his website where users can print the files but not be able to download it as PDF so as to prevent further distribution by users.
Is there any way by which I can give a print option in a website but users should not be able to download that file and just print it. I personally think this is kind of difficult as most browsers while handling a print command give the option to save the file as PDF.
I hope there is some way around it using javascript or some specialized javascript library.
It's not possible. What you print is what you download and therfor can be saved.
The only way I can think of to make it harder for the user to share the original PDF, is some server side service rendering the PDFs as images and serving those on a website which can be printed out. Of course the user could still save those images, but it wouldn't be in a PDF Format.
His best bet is to Watermark his files. Print dialog boxes now offer the option to "Print To PDF" & "Print to XPS", etc so a native ability to stop people from saving his files is not an option. I would suggest he watermark his files, that way at least his mark is on every page of all the documents.
Maybe you can encrypt the file or add a password to open it.

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.

How to disable pdf file download option using JQuery?

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...:)

Use javascript to switch pages in acrobat reader in webbrowser

For a project I am looking for a good way to display pdf files in a webbrowser (IE8 and newer). The browsers used in my project have acrobat reader installed, so thatwillbe the preferred way to visualize thepdf file.
Is there a way to access acrobat reader currently opened in a div to (for instance) switch pages or jump to a given bookmark? Is it also possible to listen for text selection events?
Thanks in advance!
I'm not sure you can control the PDF from the outside of the page. However, pdf.js is a PDF renderer written in Javascript. It allows you to embed a PDF viewer inside a page and fully control it, including flipping pages, and the like. It may just be what you're looking for!
Having worked on this problem for some time, I now use the following solution:
Use pdfObject.js to embed the pdf file in my webpage.
Communicate between pdf and html using the HostContainer. Important here is that you are able to put some javascript in the PDF file.
Important note is that this only works with the embedded Acrobat Reader/Pro version.
see: http://www.javabeat.net/articles/print.php?article_id=301)
Good luck. If you encounter problems, just leave a message, perhaps I can help.
This won't solve all of your feature requests, but you may want to take a look at the PDF open parameters. If you open a pdf with the appropriate hash-url, you can control reader's behavior.
For example, the following will open a PDF and go to the third page of the pdf:
http://example.org/doc.pdf#page=3

HTML5 / JavaScript: open text file, load into textarea / save textarea content to text file

I want to do two things in my browser:
Load a text file into a textarea (has to be choosen via dialog box)
Save the content of a textarea into a text file (has to be choosen via dialog box again)
Load a video file and grab the file path to use it with a video player (1)
I've been looking around for a while on the internet. There are some solutions for IE only via ActiveXObjects, which I can't use (IE, seriously?). HTML5 file API has limited usability because I can't access the selected file's path.
I also found save dialogs for textareas, but they ignored line breaks for some strange reason and I don't know how to fix that, if possible at all.
So here are my requirements and options:
Support for FF and Chrome
JavaScript, HTML5 (and PHP, if it has to be)
possibly Silverlight, but I'm not very familiar with it and may only copy and paste :-/
it has to work on Mac as well
There is a dirty hack that gets the job done without resorting to Flash or Silverlight, or using a server, and it works in most browsers:
var uriContent = "data:application/octet-stream," + encodeURIComponent(fileContentsAsString);
window.open(uriContent, 'Save Your File');
JS runs in a sandbox. That means: no access to files on the filesystem. HTML5 file API is the first „native” (as in not flash nor activex) attempt to grant limited access to the users file system.
The File API is HTML that would allow you to access data, after which you can manipulate binary blobs in JavaScript, but as written this is not possible in pure JS and HTML based on your requirements.
The big blocker is "saving to a text file." The only way I've been able to do this is by opening up an iFrame that calls a server side language (such as PHP) to set the content type in the header to a type that prompts a download.
Flash and Silverlight are "client" technologies that run outside of the sandbox, which sounds like your only option at this point.
My ideas:
Load a text file: Use a normal HTML upload form (if you want to script, maybe submit it via AJAX)
Save a text file: Use a textarea and upon submitting, create the file server-side and then offer it to download. (As mentioned before, client-side scripts do not have access to the computer's file system)
Load a video file: Is the video on the server already? Otherwise will need an upload just like the text file. Then use a flash plugin to play the file from the server (the URI should be known to you then)
All of these are relatively simple to achieve using PHP. Line breaks from a textarea stay as \n in PHP.
Tutorials: Form handling in PHP, File upload in PHP
Edit: Since PHP runs server-side you should not run into a lot of problems because of browser diversity. Alternatively, you can do all of these in Flash or Silverlight as well, although from my point of view that takes more learning and is less comfortable for the user.

Categories

Resources