• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Directly Open Native Print Properties

 
Robert Pepersack
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I'm writing a small printing application using javax.print. I'm very familiar with the Java Print Service, but I'm stumped, even after reading the source code of javax.print and sun.print. I want to display the native print properties dialog for the currently selected print service.

I've tried out all the variations of print dialogs that come with Java: ServiceUI.printDialog(...), PrinterJob.pageDialog(PageFormat), PrinterJob.pageDialog(PrintRequestAttributeSet), PrinterJob.printDialog(PrintRequestAttributeSet), PrinterJob.printDialog(). and ServiceUIFactory.getUI(...). None of these directly opens the native print properties window. I found that PrinterJob.pageDialog(PageFormat) displays a Java "Page Setup" dialog with a "Printer..." button that opens what appears to be a native printer select dialog. This, probably native, printer select dialog has a "Properties..." button that opens the native printer setup dialog that is installed with the printer driver.

I would like to directly open the native printer setup dialog that comes with the driver, without first having to open the previous two dialogs. Does anyone know how to do this?

Thanks.


 
Darryl Burke
Bartender
Posts: 5149
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think this could be made possible across all platforms. Is there a particular OS on which you want to establish this functionality?
 
Robert Pepersack
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the fast reply!

The client computers are running Microsoft Windows.
 
Darryl Burke
Bartender
Posts: 5149
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write a VBS script to file and execute it. Oversimplified example:You'll probably want to add to the script to write the selected properties to stdout in a format that your Java program can read and use.

Be sure to read and apply all the tips in all sections of When Runtime.exec() won't.
 
Rob Spoor
Sheriff
Pie
Posts: 20745
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does java.awt.Desktop.print(java.io.File) do?
 
Robert Pepersack
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the example.

Can I write the VBS command to open the dialog for a print service that I specify? The currently selected printer is in an observer's subject in my Java code.
 
Robert Pepersack
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked at the javadoc for java.awt.Desktop.print(java.io.File). This method prints a file.

I'm trying to get/set printer properties with a native setup dialog.
 
Darryl Burke
Bartender
Posts: 5149
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert Pepersack wrote:Thanks for the example.

You're welcome.

Can I write the VBS command to open the dialog for a print service that I specify? The currently selected printer is in an observer's subject in my Java code.

That would be a topic for a VBS forum , I would think. edit: On the Java side, you would want to pass a parameter to the script to specify the printer. Note: I don't know enough VBScript to even know if that's possible (identifying the printer, that is -- a parameter can certainly be passed).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic