This discussion is archived
3 Replies Latest reply: Feb 8, 2013 8:45 AM by Maxideon RSS

Java printing

989313 Newbie
Currently Being Moderated
Hi,

I'm a bit confused by the PrintJob and how it works.

When the PrintJob is created, it opens the print dialog. I am using a PDF printer to test with. Like many physical printers, the dialog for this PDF printer includes a setting for DPI. However, it appears this is being ignored by the print job as I can't figure out how to retrieve this setting.

I pass in a PageAttributes object, but this allows the DPI to be set to any value manually, even if it's not supported. Changing the DPI in the printer dialog does not effect this setting. Is this correct?

It appears that PrintService can be used to obtain the supported DPI of the printer (if supported), but I can't find a way to get the user selected value.

Can anyone please point me in the right direction?

Thanks.
  • 1. Re: Java printing
    Maxideon Explorer
    Currently Being Moderated
    You're drawing some things, right? How do you determine how many pixels will be one inch on the page? That's the PageAttributes resolution setting.

    How do you determine how much ink to to use to faithfully reproduce the pixels? Thats the print dialog's resolution setting. It should correspond to the PageAttributes print quality setting.
  • 2. Re: Java printing
    EJP Guru
    Currently Being Moderated
    How do you determine how many pixels will be one inch on the page? That's the PageAttributes resolution setting.
    No. "printerResolution: Specifies the desired cross feed and feed print resolutions in dots per inch for pages using these attributes. The same value is used for both resolutions. The actual resolutions will be determined by the limitations of the implementation and the target printer. Not specifying the property is equivalent to specifying 72".
    How do you determine how much ink to to use to faithfully reproduce the pixels? Thats the print dialog's resolution setting.
    No. It's not how much ink. It's how many DPI the printer uses to reproduce what Java sends it. At higher DPI you would probably use slightly less ink, but it's very marginal.
  • 3. Re: Java printing
    Maxideon Explorer
    Currently Being Moderated
    No. "printerResolution: Specifies the desired cross feed and feed print resolutions in dots per inch for pages using these attributes. The same value is used for both resolutions. The actual resolutions will be determined by the limitations of the implementation and the target printer. Not specifying the property is equivalent to specifying 72".
    So 72 pixels per inch, right? Set it to 200, and you'll get the printer trying to squeeze 200 pixels into one inch, essentially photo quality if your printer can do that. Isn't that what the documentation is saying? I forget how this particular setting interplays with the AffineTransform set on the graphics object when drawing what you want to print, but I don't see how what I said is wrong.
    No. It's not how much ink. It's how many DPI the printer uses to reproduce what Java sends it. At higher DPI you would probably use slightly less ink, but it's very marginal.
    How would a higher DPI, say 1200 vs 600, use less ink? You're telling the printer to improve the quality which should almost always equate to more ink. Certainly you run out of ink cartridges faster if you're constantly printing out higher quality papers (1200 dpi) vs. the default option (600 dpi) or "fast draft" (300 dpi)?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points