Page resolution (DPI) in Java 1.4 printing

Discussion in 'Java' started by Ixtlan, Oct 17, 2003.

  1. Ixtlan

    Ixtlan Guest

    I got a problem with how to set the DPI of my printout to more than 72 DPI
    (I'm using JDK 1.4.2)

    I has somehow managed to learn that one should use java.awt.PageAttributes,
    bug the Java documentation tersely states that :

    "A set of attributes which control the output of a printed page.
    ............"

    Great! So that's how it's done!

    My problem is that I want to print a jpeg file that looks good in resolution
    300 DPI, but looks crappy in 72 DPI (scaled in Photoshop).

    So how to set the resolution to other than 72 DPI?

    Any comments/links greatly appreciated!

    RCS
     
    Ixtlan, Oct 17, 2003
    #1
    1. Advertising

  2. Ixtlan () wrote:
    : I got a problem with how to set the DPI of my printout to more than 72 DPI
    : (I'm using JDK 1.4.2)

    : I has somehow managed to learn that one should use java.awt.PageAttributes,
    : bug the Java documentation tersely states that :
    : ....
    : So how to set the resolution to other than 72 DPI?

    I have no problems printing in higher than 72 dpi. I used to have
    that problem when I tried to print swing components that were double
    buffered, have you tried turning that off?

    componentToBePrinted.setDoubleBuffered (false);

    /robo
     
    Robert Olofsson, Oct 17, 2003
    #2
    1. Advertising

  3. Ixtlan

    Ixtlan Guest

    My problem is not that the printing does not work, it is that the jpeg image
    (that I load from disk) does not look good in 72 DPI (nothing to do with
    Java here, it does not look good in Photoshop or other viewers).

    My real problem is: how to set the DPI higher than the default 72 in the
    Java printing API?

    RCS

    "Robert Olofsson" <> skrev i melding
    news:bmp76o$8pi$...
    > Ixtlan () wrote:
    > : I got a problem with how to set the DPI of my printout to more than 72

    DPI
    > : (I'm using JDK 1.4.2)
    >
    > : I has somehow managed to learn that one should use

    java.awt.PageAttributes,
    > : bug the Java documentation tersely states that :
    > : ....
    > : So how to set the resolution to other than 72 DPI?
    >
    > I have no problems printing in higher than 72 dpi. I used to have
    > that problem when I tried to print swing components that were double
    > buffered, have you tried turning that off?
    >
    > componentToBePrinted.setDoubleBuffered (false);
    >
    > /robo
     
    Ixtlan, Oct 17, 2003
    #3
  4. Ixtlan

    Steven Green Guest

    I am not sure if it will work or not since I have not tested it, but you
    might try setting a print attribute PrinterResolution.

    Just lookup the PrinterResolution class to find it.

    --Steve


    On Fri, 17 Oct 2003 18:33:36 +0200, Ixtlan wrote:

    > I got a problem with how to set the DPI of my printout to more than 72 DPI
    > (I'm using JDK 1.4.2)
    >
    > I has somehow managed to learn that one should use java.awt.PageAttributes,
    > bug the Java documentation tersely states that :
    >
    > "A set of attributes which control the output of a printed page.
    > ..........."
    >
    > Great! So that's how it's done!
    >
    > My problem is that I want to print a jpeg file that looks good in resolution
    > 300 DPI, but looks crappy in 72 DPI (scaled in Photoshop).
    >
    > So how to set the resolution to other than 72 DPI?
    >
    > Any comments/links greatly appreciated!
    >
    > RCS
     
    Steven Green, Oct 18, 2003
    #4
  5. Ixtlan

    RCS Guest

    I checked the PrinterResolution (throug Eclipse's look-up mechanism, no
    hint of this class in the Java documentation), and found that the
    resolution attribute is read only, no setResolution, only getResolution.

    Thanks for answering, though!

    RCS


    Steven Green wrote:
    > I am not sure if it will work or not since I have not tested it, but you
    > might try setting a print attribute PrinterResolution.
    >
    > Just lookup the PrinterResolution class to find it.
    >
    > --Steve
    >
    >
    > On Fri, 17 Oct 2003 18:33:36 +0200, Ixtlan wrote:
    >
    >
    >>I got a problem with how to set the DPI of my printout to more than 72 DPI
    >>(I'm using JDK 1.4.2)
    >>
    >>I has somehow managed to learn that one should use java.awt.PageAttributes,
    >>bug the Java documentation tersely states that :
    >>
    >> "A set of attributes which control the output of a printed page.
    >>..........."
    >>
    >>Great! So that's how it's done!
    >>
    >>My problem is that I want to print a jpeg file that looks good in resolution
    >>300 DPI, but looks crappy in 72 DPI (scaled in Photoshop).
    >>
    >>So how to set the resolution to other than 72 DPI?
    >>
    >>Any comments/links greatly appreciated!
    >>
    >>RCS

    >
    >
     
    RCS, Oct 18, 2003
    #5
  6. Ixtlan

    Steven Green Guest

    The constructor for PrinterResolution takes the resolution.
    You simply create a new PrinterResolution and add it to the attribute set
    passed to the PrintJob print method. For example:
    aset.add(new PrintResolution(600,600,PrintResolution.DPI)

    I tested this with my output files, but found no effect on the postscript
    file that was generated. Not sure if the effect is different if it is not
    writing to a file.

    --Steve


    On Sat, 18 Oct 2003 14:20:39 +0200, RCS wrote:

    > I checked the PrinterResolution (throug Eclipse's look-up mechanism, no
    > hint of this class in the Java documentation), and found that the
    > resolution attribute is read only, no setResolution, only getResolution.
    >
    > Thanks for answering, though!
    >
    > RCS
    >
    >
    > Steven Green wrote:
    >> I am not sure if it will work or not since I have not tested it, but you
    >> might try setting a print attribute PrinterResolution.
    >>
    >> Just lookup the PrinterResolution class to find it.
    >>
    >> --Steve
    >>
    >>
    >> On Fri, 17 Oct 2003 18:33:36 +0200, Ixtlan wrote:
    >>
    >>
    >>>I got a problem with how to set the DPI of my printout to more than 72 DPI
    >>>(I'm using JDK 1.4.2)
    >>>
    >>>I has somehow managed to learn that one should use java.awt.PageAttributes,
    >>>bug the Java documentation tersely states that :
    >>>
    >>> "A set of attributes which control the output of a printed page.
    >>>..........."
    >>>
    >>>Great! So that's how it's done!
    >>>
    >>>My problem is that I want to print a jpeg file that looks good in resolution
    >>>300 DPI, but looks crappy in 72 DPI (scaled in Photoshop).
    >>>
    >>>So how to set the resolution to other than 72 DPI?
    >>>
    >>>Any comments/links greatly appreciated!
    >>>
    >>>RCS

    >>
    >>
     
    Steven Green, Oct 20, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Swapnajit Mittra
    Replies:
    0
    Views:
    1,064
    Swapnajit Mittra
    Sep 21, 2004
  2. Andrew FPGA
    Replies:
    0
    Views:
    1,009
    Andrew FPGA
    Sep 26, 2005
  3. Allen E. Scharfenberg

    Java Advanced Imaging at 204x98 dpi

    Allen E. Scharfenberg, Oct 31, 2003, in forum: Java
    Replies:
    1
    Views:
    799
  4. dwilson
    Replies:
    0
    Views:
    1,252
    dwilson
    Apr 8, 2005
  5. Replies:
    3
    Views:
    759
    Do Re Mi chel La Si Do
    Aug 22, 2005
Loading...

Share This Page