Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java raw Postscript printing, sending XPS_PASS (Windows specific)

Newer XPS print drivers (almost all Windows 8 print drivers) require DOCINFO.pDataType = "XPS_PASS" (instead of "RAW") to pipe raw print jobs (Postscript/PCL/ZPL/etc).
(Send Postscript Document to Printer using VC++)
(How to make RawPrinterHelper work in both XPS_PATH and RAW data types?)

Other than using something like JNA, is there a way to do this in a Java applet/application?
I can use JNA, and plan to use it for printer management, but I'd rather the actual printing not have to delve into JNA - Win32 API territory.

NOTE: I also want to avoid having to pipe directly to 9100, serial ports, etc. Makes more sense to make use of already detected/configured printers.

WORKAROUND: I've had success using JNA and JOB_INFO to send "XPS_PASS". Can use PRINTER_INFORMATION_4 and DOCINFO_4/DOCINFO_8 (implement structs yourself) to detect if XPS_PASS or RAW should be sent. See C++ examples

like image 980
user120242 Avatar asked Mar 19 '15 07:03

user120242


1 Answers

JNI is the only choice right now. Should probably be filed as a bug report to Java issue tracker.

JDK8 source: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/windows/native/sun/windows/WPrinterJob.cpp#l999

JDK9 source: http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/c0ed608fc7d2/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp#l1060

Unfortunately, it is not possible as the DOCINFO.pDataType is hardcoded to "RAW", and there does not appear to be any other entrypoints to printing in the JVM.

like image 136
user120242 Avatar answered Oct 06 '22 00:10

user120242