Jump to content

Print a PDF file from the server to the client without displaying file


dmikester1

Recommended Posts

Anyone know how I can print a file (specifically a PDF) that is stored on the server to the clients computer with a button?  I don't want them to be able to view it, just print it.  I've done some research and understand that there is no way to print directly without popping up the Windows Print dialog.  And that is fine.  I just want them to print this file, but not no where it is or be able to type in a URL to access it.

Thanks

Mike

Link to comment
Share on other sites

I don't believe it is possible via a Web Server/Client methodology. I know there is technology to print via the internet (i.e. while at work I could print something on my home PC). Although, I've never needed to do that so I don't know the specifics. But, I'm pretty sure the client machine has to have access to the file. Generally speaking, the computer that is sending the job to the printer is responsible for determining "how" the file is rendered. Although, you can do some things with PostScript files to send to the printer directly and the printer will do the rendering itself. But, even if you could do something like that, many printers don't have that capability.

 

In the end, it would also seem like a security issue. Just think about some malicious site that would randomly start printing stuff to your printer. If you can do it, so would others. And they definitely would.

 

If you are allowing the user to print the file, what objection do you have to them viewing it. They could just scan the printed page to make their own PDF anyway. Maybe what you really want to do is to secure the PDF, which is definitely doable.

Link to comment
Share on other sites

 

Putting the file in a non web-accessible location doesn't do what the OP is asking for. He wants the users to be able to print the file without viewing it. They would still have to access the file regardless if it is in a web-accessible location or not is not the issue.

Link to comment
Share on other sites

I already have the folder access denied with a .htaccess file.  I was thinking about writing a script that would copy the file to a temp directory, print it, then delete the temp file.  I just can't figure out how to print the file in PHP without displaying it.  I realize the user can scan it and make copies, but at least we are partially preventing duplicating.

Link to comment
Share on other sites

Per OP

just want them to print this file, but not no where it is or be able to type in a URL to access it.

 

IMHO that means make it non accessible.

 

True, but the core issue is about being able to print the file without accessing it.

 

I was thinking about writing a script that would copy the file to a temp directory, print it, then delete the temp file.  I just can't figure out how to print the file in PHP without displaying it.  I realize the user can scan it and make copies, but at least we are partially preventing duplicating.

 

A temp directory where? on the user's machine? You have no control over files that are sent to the user - none. I've seen many sites that try to "secure" content via JavaScript by disabling the view source feature or using transparent images over content. Those are all useless, because 1) the user can typically disable the features that are preventing them and the content is already stored in their browser cache. The web server cannot control what the user's machine does with the files/content it sends them. So, those files are just sitting in the user's cache to do whatever they want with them.

 

You should really look into the protection features available in PDFs. Take a look here: http://www.locklizard.com/pdf_security_features.htm

 

Link to comment
Share on other sites

The temp directory would be on the server.  I have no doubts that anyone determined would be able to bypass the restrictions, but for legal purposes we have to make it look like we at least tried some prevention and security.  My co-worker said something he has found is that some people end up converting the pdf to an swf file to get the security they desire.  Maybe we'll end up going that route.  That locklizard looks nice, but pretty pricey.

Thanks for the answers.

Mike

Link to comment
Share on other sites

Found a script that will password protect a pdf and dis-allow printing in the pdf file.  This could be helpful: http://www.idsecuritysuite.com/blog/password-protect-a-pdf-document-in-php

 

Not to be rude, but have you actually read this thread? He wants the user to print the PDF, but not view it.

 

@dmikester1, there are plenty of other solutions for securing a PDF file, I simply provided a link to one possible resource. There are plenty of PDF security measures available. But, if you have a flash solution, go for it. This all seems hokey to me, but it's your product.

Link to comment
Share on other sites

I did find this, but not sure if its a valid option for what you want to achieve

http://stackoverflow.com/questions/3915500/how-to-enable-direct-printing-capabilities-for-web-based-application

Regarding the storing in a htaccess deny from all directory, I just did this with my own version of captcha I made.

I have Images in a protected directory, I use php to select a random image in my case, and I copy it to what I call a transfer directory with a new name, the new name is a md5 of time(), a salt and part of the original image name, so no matter which image gets loaded the name is never the same, I delete all images in the directory with every page load so its only valid for the 1 time it is shown, I am guessing a combination of something like that and the hidden iframe solution in the above link may suit your needs.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.