Direct Printing a pdf file in local drive from a web - javascript

I have an online web page and in this page there is a form with submit button. What I want is now to print a test.pdf file (always the same file) located in my local drive when I click the submit button. Is is possible to send this file to the printer installed in my local network by clicking the submit button on an online web page?
in other words:
Web page is online and it is on a different server.
Pdf file is located in my local drive.
I want to write a code on my online web page that always send the same pdf file to the printer installed in local network!
If it is possible, can anyone explain please? I searched a lot on web but could not find what I want!

The PECL printer library is for server-side printing. You have to have the printer connected to the server the script is running on.
If your clients need to do the printing, you cannot use it. You cannot do the printer queueing with JS alone. If you are restricted to using the browser only, best way to go about this would be loading out all the pages you want to print in one HTML page with proper CSS page breaks. But beware, there might be browser performance issues depending on the size of that one page.
Another thing you could do is convert that HTML internally to a PDF and then allow clients to print it. This doesn't allow queueing, but serves the purpose.

Related

How to print using print.js in ionic application without opening printer setup page

We are developing ionic web application with printer functionality. We used Print.js npm to print the content. There is a page open in browser when we call print method. We can see the information like printer name, no.of pages and so on. Our requirement is to print the content without showing that setup page ionic application.
This can't be done with Javascript alone. One of the reasons is for our own security. Imagine if you open a webpage, and it starts printing lots of page without any warning. That wouldn't be a good thing.Another reason is to allow the user to confirm / select the printer where the job will be sent to.
Ref: https://github.com/crabbly/Print.js/issues/130

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.

add print and download protected pdf viewer to web site

Is there any way to add slide share like PDF viewer to the web site?
Only users can be able to view document... print or download can't be done.I tried several JavaScript plugins for doing that but unable to find one that has no print and downloadable options. And also client can disable JavaScript in browser therefore I think of that suitable server side script.
I also unable to find a server side script (PHP) for this. Please suggest.
Just keep the file outside the web root directory because the web browser follows the local file system privileges and not its own. Put them into a directory with a .htaccess file that blocks all communication.
Ex: Order deny,allow
deny from all
I don't know how much it will gonna help you.

Force ask where save file before download

I have an embedded system with a web server Mongoose, I have to allow the client to download some log files generated at runtime, I have a problem during the download, in practice, the browser first downloads the file and then asks where to save the file .
The behavior is unpleasant because the download takes a few seconds and the client does not understand what's going on.
Is there any option, for example, in the header of the file, to force the browser to ask before making the download where to save the file?
Thanks.
it is not up to you to decide how the client's browser is behaving.
if the browser is set to save the file automatically in a specific place, then there is nothing you can do.
your only workarounds is to either upload your file somewhere and suggest the viewer to right-click a download link that points to the file, it will open the dialog,
or suggest the viewer to change browser settings,
or write a browser extension that does that and offer viewers to install it.

JavaScript downloader

I want to allow a web site users to be able to download files from my site, but with the help of a client-side downloader with an ability to continue an interrupted download.
For example, I want to sent a person a file with a size of 30+ Meg. I want the user to have the best downloading experience, so I can't afford him downloading 25 Meg and then getting the download dropped due to the network problems on his side.
Therefore, I want to have a javascript downloader rendered on a download page, that will show the actual client-side file delivery, and when it is downloaded, to give an ability to a user to save the file.
Or is it not possible due to the fact that javascript won't be able to open a save file dialog and save to a file system?
I'm afraid that is not possible with JavaScript and that's why:
To continue downloading from the certain point you should send to the server the position number to start downloading from. And as JavaScript has no access to local file system, you can't get that position.
UPD: it seems that I was too hurrying with the reply.
The file size can be gotten using the HTML5 File API and after getting the file size you can pass it to the server which should support the partial downloading.
But anyway, after downloading another part of the file you should sew two pieces together in some way; standard web browser dialog will only suggest to overwrite the file.
UPD2: to work with files in some Internet Explorers you can use FileSystemObject:
var fso;
fso = new ActiveXObject("Scripting.FileSystemObject");
I'd look into making a plugin or extension. Like those DownloadThemAll extensions for firefox and Google chrome. Another alternative would be to use Flash, either alone or integrating it with javascript like hinted here: http://www.communitymx.com/content/article.cfm?cid=0922A

Categories

Resources