Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Page resolution (DPI) in Java 1.4 printing (http://www.velocityreviews.com/forums/t127738-page-resolution-dpi-in-java-1-4-printing.html)

Ixtlan 10-17-2003 04:33 PM

Page resolution (DPI) in Java 1.4 printing
 
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













Robert Olofsson 10-17-2003 05:00 PM

Re: Page resolution (DPI) in Java 1.4 printing
 
Ixtlan (ixtlan@freeroaming.net) 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 10-17-2003 05:16 PM

Re: Page resolution (DPI) in Java 1.4 printing
 
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" <d94-rol@tjatte.nada.kth.se> skrev i melding
news:bmp76o$8pi$1@news.kth.se...
> Ixtlan (ixtlan@freeroaming.net) 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




Steven Green 10-18-2003 01:40 AM

Re: Page resolution (DPI) in Java 1.4 printing
 
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 10-18-2003 12:20 PM

Re: Page resolution (DPI) in Java 1.4 printing
 
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 10-20-2003 07:41 PM

Re: Page resolution (DPI) in Java 1.4 printing
 
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

>>
>>




All times are GMT. The time now is 06:06 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.