File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Directly Open Native Print Properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Directly Open Native Print Properties" Watch "Directly Open Native Print Properties" New topic
Author

Directly Open Native Print Properties

Robert Pepersack
Greenhorn

Joined: Aug 09, 2007
Posts: 8
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

Joined: May 03, 2008
Posts: 4664
    
    5

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?


luck, db
There are no new questions, but there may be new answers.
Robert Pepersack
Greenhorn

Joined: Aug 09, 2007
Posts: 8
Thanks for the fast reply!

The client computers are running Microsoft Windows.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

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

Joined: Oct 27, 2005
Posts: 19785
    
  20

What does java.awt.Desktop.print(java.io.File) do?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Robert Pepersack
Greenhorn

Joined: Aug 09, 2007
Posts: 8
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

Joined: Aug 09, 2007
Posts: 8
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

Joined: May 03, 2008
Posts: 4664
    
    5

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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Directly Open Native Print Properties