开发者

printer driver implementation in java

I need to implement a custom printer driver which does the following in the backgroud:

  1. Create a PDF document of the document to print
  2. Send the created PDF document to a predefined email address OR call a web service and transmit the document there

The pinterdriver should be available for windows and mac osx. My prefered implementat开发者_StackOverflowion language is Java.

Is this possible with Java? Are there frameworks available which reduce the coding effort to a minimum?


Are you sure "driver" is really the word you are looking for here? Usually when one says a print driver they actually mean something that translates document data into commands for a printer. I think you are really looking for something of a pre-processor.

In any case, if you want it to look like a printer to the OS, it will be almost impossible to do purely in Java. Your best bet would be to create drivers for each of the platforms that use JNI(or just invoke a JVM), do your processing, then forward it on to the printer.

Although I do not know if a similar approach will work on Windows, what you want to do is almost trivial to do on OS X. Apple already provides a cups-pdf service that converts any printable document into a pdf, all you have to do is take that output, forward it to where it needs to go, then forward it to a printer, no need to do anything in Java.

For an example of how to do this, check out the following project:

https://bitbucket.org/codepoet/cups-pdf-for-mac-os-x/downloads


Windows can be configured to send printer output to a file. You can create a printer in Windows that uses a PostScript driver, and writes it to c:\myfile.txt In Windows: Add a Printer, Select Local printer, Select Create a new port, and type the file name (Full path) you want to use. Then pick the driver you want, which your Java program will have to parse. Generic text could be useful in some cases, or Postscript if you need all that formatting, and can handle parsing it.

Unlike the "File:" option under existing ports, it will not ask the user for a filename. It will just automatically save to the specified file every time.

Your Java program can monitor this file for changes, and then process the data it receives.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜