Gabe
Gabe

Reputation: 549

Create a virtual printer in Java

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.

Upvotes: 5

Views: 8651

Answers (3)

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.

Upvotes: 6

f3lix
f3lix

Reputation: 29879

RedMon

You could use RedMon to pipe the printed output into a Java program. Together with a Standard postscript driver this would give you Postscript that can be read and post-processed by your Java program.

The RedMon port monitor redirects a special printer port to a program. RedMon is commonly used with Ghostscript and a non-PostScript printer to emulate a PostScript printer.

RedMon can be used with any program that accepts data on standard input.

Upvotes: 0

Vijay Mathew
Vijay Mathew

Reputation: 27164

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

Upvotes: 3

Related Questions