• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Directly Open Native Print Properties

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the fast reply!

The client computers are running Microsoft Windows.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22683
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic