以编程方式禁用“打印到文件” [英] Programmatically disable 'printing to file'

查看:133
本文介绍了以编程方式禁用“打印到文件”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个现有的用Java编写的跨平台(Mac,Windows,Linux)应用程序,该程序以编程方式将文档发送到默认打印机,而不显示打印对话框。

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.

在不同的平台上,可以设置打印机以打印到文件。例如,在Windows中,可以将XPS Document Writer设置为默认打印机,或者更改打印机的属性,使其保留所有文档的文件副本。

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.

是否可以检测到?我愿意接受任何建议,但是该解决方案必须跨平台使用。我以为这些细节太低了(取决于平台),因此Java解决方案可能不可行,但如果可能的话将是理想的选择。

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!

编辑:

我意识到这里有很多非技术性的问题,这些问题可能引起很多讨论(谁曾想到呢?)。我想说明一下,我不是DRM的拥护者(正如人们所说的那样),并且不打算变得邪恶:)。

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.

推荐答案

否。

您可以进行各种与操作系统有关的怪异检测(使用 somedriver.dll 吗?)或命名-sniffing(它是否包含'XPS'?),但最后:

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)我如何打印与您无关我的文档

  • 2),由于所涉及的抽象,几乎不可能检测到给定的逻辑打印机是否将实际打印到物理打印机或其他地方;

  • 3)更不用说网络驱动程序了( \\joescomputer\someprinter 是什么?)很难说:可能是打印机,可能是一个PDF生成器,可能是Matilda姨妈;网络在您的程序和物理硬件之间增加了另一层抽象)

  • 4)如果我真的很想要非纸质副本,我ll截取屏幕截图甚至是真实照片,或者

  • 5)从物理打印机上取走那可恶的纸张打印输出,并通过扫描仪送入,无缘无故地指责您弄乱了我的工作流程。

  • 请注意,6)中型和大型打印解决方案,它公开了网络打印机界面,然后允许用户对文档进行很多操作(当时,该文档仅作为服务器上的假脱机文件存在):在连接到系统的任何 n 打印机上,通过电子邮件,传真等方式进行,因此您无法预先知道文档是否将进行物理打印(或在何处打印),即使是打印作业离开计算机。

  • 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.

您实际上是在略有不同的环境中进行DRM战斗(这不是道德判断,而是声明事实上:我想限制我的软件用户的选择是DRM的核心,也是您的问题-不管我对这个问题有何看法);如您所知,它们很杂乱,并且具有令人不快的副作用(您的意思是,我无法在物理打印机上打印,因为它名为WinXPStation?!?我的防病毒软件表示您的软件正在尝试与我的打印驱动程序,您在推动间谍软件吗?!?),并且它们是无法解决的-始终存在解决方法。

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.

什至不考虑实际上禁用您可能会认为的是打印到文件的驱动程序:请注意索尼的DRM惨败,并请注意您可能会因非法篡改计算机而受到起诉。

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.

更切合实际的是,如果您的软件禁用了系统的其他部分,然后由于 disabled 禁用了该部分,那么您将无法使用。 我安装了NigelSoft的SomeSoftware,它使我的打印机坏了,这不是一个好名声,而且很难删除-人们会抱怨,而且,无论互联网上发生什么,都可能永远存在(请注意您所遇到的各种类似事件)将通过搜索((防病毒供应商)破坏Windows来发现)。还请注意,有问题的供应商会不满意:您的#@ $ @软件故意破坏了我的Wonderful Special Rainbow打印机(tm),您欠我们的钱我们必须退还,这是针对您的几项诉讼。

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".

换句话说,我觉得这背后存在一些非技术性的要求,但是-不幸的是-不能完全通过技术手段解决(而且绝对不能通过Java的深层抽象)。您可能需要走法律路线,例如包括不允许以电子方式保存打印输出,并在要求打印的每个位置以红色闪烁的大字母显示此内容。这将与技术解决方案一样无效,但对于CYA来说可能就足够了(因为您将很明显地将决定权移交给用户)。

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

这篇关于以编程方式禁用“打印到文件”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆