Objective
In a previous article, the Java Printservice API was introduced, although it supports print functionality, but does not have the ability to interpret documents such as PDF, MS Word, and so on.
And because printers that support post script standards are often expensive, inexpensive printers circulating on the market (using host-based drivers) are largely unsupported.
And the previous article provided a way to print PDFs using Adobe Reader, this article is in the same fashion, but with GSview.
GSview is more capable of silent printing than Adobe Reader, because I always pop up a window of Adobe Reader Center in the process of using Adobe Reader, and it's disgusting ~ and I can't find a workaround.
There is no such situation when using GSview.
Preparatory work
First go to GSview's official online download GSview The latest version, here by the way GSview's official website,
I'm using Gsv50w32.exe and Ghostscript 9.15, and these two versions need to be matched to the main program, followed by something like the script interpreter (engine) or the environment.
Specific use
public static void Printbygsview (string printername, String filePath) {try {runtime.getruntime (). EXEC ("cmd.exe/c Gsprint-printer \ "" + PrinterName + "\" "+ FilePath);} catch (IOException e) {e.printstacktrace ();}}
Where the-printer parameter can specify the printer by name
Java calls GSview to print PDFs