Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a virtual printer in Java

Tags:

java

printing

I would like to create a virtual printer using Java, so that when you go to print a file( using Word or something) the Java printer is listed as a valid printer. My goal is to get the printer formatted object that the programs (Word, etc..) send directly to the printer. I don't know if this is possible. It seemed like a more logical solution to this question:

Printing multiple file types using java

Any ideas? I heard this is only possible using C or C++, but I don't know for sure.

like image 475
Gabe Avatar asked Jan 22 '23 00:01

Gabe


2 Answers

There is a LPD implementation available in Java. You can then create manually a printer in Windows which use the LPR protocol to print to said Java LPD. This captures the result as a byte stream which you can then manipulate further.

like image 155
Thorbjørn Ravn Andersen Avatar answered Jan 30 '23 20:01

Thorbjørn Ravn Andersen


You will have to write a new printer driver that re-direct API calls to your Java classes.

like image 23
Vijay Mathew Avatar answered Jan 30 '23 20:01

Vijay Mathew