Skip to main content

Attributes

2 replies [Last post]
freesoft_2000
Offline
Joined: 2005-09-06

Hi everyone,

I have a question to ask about printer attributes. I am using the PrintRequestAttributeSet class and am a bit confused as to whether i will still have to use the PageFormat class to set the page format of my printed page.

See this below function

</p>
<p>public void prt( )<br />
{<br />
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet( );</p>
<p>prnJob = PrinterJob.getPrinterJob( );<br />
PageFormat format = prnJob.defaultPage( );</p>
<p>//Do i still have to include the format in the below statement or<br />
//can i leave it out</p>
<p>prnJob.setPrintable(myprintableclass, format);</p>
<p>if (prnJob.printDialog(aset) == false)<br />
{<br />
return;<br />
}</p>
<p>prnJob.print(aset);<br />
}</p>
<p>

Basically i don't know that if i use the PrintRequestAttributeSet class the will page format will be passed to the printable like the PageFormat class
like its statement above

</p>
<p>prnJob.setPrintable(myprintableclass, format);</p>
<p>

I hope i have not confused you guys

I hope someone can help me with this confusion of mine

Thank You

Yours Sincerely

Richard West

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
shan-man
Offline
Joined: 2006-02-17

Hi Richard,

No, you don't need to set the page format explicitly. By passing to print() the attributes that you previously passed to printDialog(), print() will get the pageFormat as configured by the print dialog - either the default, or whatever was customized by the user.

Regards,
Shannon

freesoft_2000
Offline
Joined: 2005-09-06

Hi everyone,

Thank you for clearing that up for me.

Yours Sincerely

Richard West