Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically disable 'printing to file'

We have an existing cross-platform (Mac, Windows, Linux) application written in Java, that programmatically sends a document to the default printer without showing a print dialog.

Across different platforms it is possible to set up a printer to print to file. For example in Windows it is possible to set the XPS Document Writer as the default printer, or to change the properties on a printer such that it keeps a file copy of all documents.

Is it possible to detect this? I'm open to any suggestions, but the solution must work cross-platform. I am assuming that such details are too low level (and platform dependent) so a Java solution is probably not feasible, but would be ideal if possible.

We're not necessarily looking for a bullet-proof solution, so any suggestions would be helpful, no matter how wacky!

Edit:

I realise there's a whole host of non-technical issues here, which could provoke a lot of discussion (who'd have thought it?). I want to make it clear that I am not a fan of DRM (as this has been likened to) and not trying to be evil :).

I appreciate that these issues are real, and when making my recommendations I will make this very clear. However I do have to investigate the technical solution before I can do this.

like image 719
Nigel Avatar asked Apr 14 '11 12:04

Nigel


People also ask

How do I stop printing before saving?

From the printing dialog of Chrome click the Change button and change from Save as PDF to your printer, then it should print instead of saving the file.


1 Answers

No.

You could do all kinds of weird OS-dependent detection (is it using somedriver.dll?), or name-sniffing ("does it contain 'XPS'?") but in the end:

  • 1) it's none of your business how I print my documents,
  • 2) due to the abstractions involved, it's practically impossible to detect whether the given logical printer will actually print to a physical printer or somewhere else;
  • 3) this is not to mention network drivers (what is at \\joescomputer\someprinter? Hard to tell: could be a printer, could be a PDF generator, could be aunt Matilda; network adds another layer of abstraction between your program and the physical hardware)
  • 4) if I really really really want a non-paper copy, I'll take a screenshot or even an actual photo, or
  • 5) take the damn paper printout from the physical printer and feed it through a scanner, cussing at you for messing with my workflow for no good reason.
  • Note also that 6) there are medium- and large-scale printing solutions that expose a "network printer" interface, and then allow the user to do many things with the document (which at that point only exists as a spool file on a server somewhere): print at any of the n printers connected to the system, e-mail, fax, whatever - so you don't know in advance whether the document will physically print (or where), even as the print job leaves the computer.

You are essentially fighting a DRM battle in a slightly different setting (this is not a moral judgement, but a statement of fact: "I want to limit the choices that users of my software have" is the core of DRM, and of your question - regardless of any opinion I may have on the subject); as you may be aware, those are messy and have unpleasant side effects ("what do you mean, I can't print on my physical printer because it's named WinXPStation?!?" "my antivirus says that your software is trying to mess with my printing drivers, are you pushing spyware?!?"), and they are unwinnable - there's always a workaround.

Don't even think of actually disabling something you may think is a print-to-file driver: note Sony's DRM fiasco, and note that you might get sued for illegally tampering with the computer.

On a more pragmatic note, if your software disables some other part of the system, and then that other part doesn't work because it's disabled, word will get out. "I installed SomeSoftware by NigelSoft, and it broke my printer" is not a good reputation to acquire, and hard to erase - people will complain, and, well, whatever goes on the Internet might remain there forever (note the various similar incidents you'll discover by searching for "(antivirus vendor) breaks Windows"). Note also that the vendor in question will be less than happy: "your #@$@ software is wilfully breaking my Wonderful Special Rainbow Printer (tm), you owe us the money we had to refund, aaand here's a couple of lawsuits against you".

In other words, I feel there is some non-technical requirement behind this, which - unfortunately - is not solvable purely by technical means (and definitely not with the deep abstractions of Java). You may need to go the legal route, such as including a "you are not allowed to save the printouts electronically" and showing this in huge red blinking letters at every point where printing is requested. This will be similarly ineffective as the technical solution, but may be enough to CYA (as you'll be clearly shifting the decision to the user).

like image 89
Piskvor left the building Avatar answered Oct 26 '22 14:10

Piskvor left the building