0

How can I print a PDFs silently from a Java application? I do not want the 'print preview' option to show up, but it does show up in Google Chrome. Is there any other way to print PDFs silently, like by using an applet?

Simon
  • 1,416
  • 1
  • 15
  • 24
Raghunath
  • 1
  • 7
  • 1
    The print dialog serves an important purpose for the user. It lets them choose what printer they want to print to, what printer settings they want to use, choose which pages they want to print, see in advance (in some cases) how many pages they'll get. I recommend not even trying to bypass it. As a user, if I clicked "print" in an app or on a web page and it didn't show me a print dialog and just bypassed me, I'd stop using that app/page. – T.J. Crowder Oct 29 '14 at 09:53
  • we can't stop print preview option in google Chrome as it is in build feature. If you want then you have to explicit configure browser of each machine. It is not possible to do in java code. – Raghunath Feb 04 '16 at 15:54

2 Answers2

0

You can't print "silently" with JavaScript in a browser.

You could with a signed Java applet that doesn't run in the sandbox. The user would have to allow the applet to run, which most users probably wouldn't do. You'd also have the issue that the Java plugin will soon no longer be supported in Chrome because Chrome is dropping all support for NPAPI plugins (already has done on Linux). NPAPI plugins are also not supported in "metro" mode in IE, and they may be dropped by Firefox at some point as well. Bottom-line, doing it through a Java applet will be time-consuming, awkward, and may not even work depending on your user base.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • Is any otherway to print silently.CAn we do any batch job for that.But user won't be able to see preview. – Raghunath Oct 29 '14 at 09:59
0

The answer is nearly identical to one here: https://stackoverflow.com/a/28783269/3196753

In short, you'll need some middleware installed on the PC or mobile device that is silently printing in order to communicate with locally attached devices silently. If your devices are exposed to the same network as your web server, you may be able to leverage a server-side solution instead.

Full disclaimer, we're the authors of the last solution in that listing.

Community
  • 1
  • 1
tresf
  • 7,103
  • 6
  • 40
  • 101