[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1175
  • Last Modified:

How to set PrinterResolution with using java.awt.Print.PrintJob object


Hi Experts
I have used java.awt.Print.PrintJob and PageFormat object to develop a print java app

But I want to set printer resolution when I print.

How can to do this, please help me!

Thank in advance!
 
0
CongUan
Asked:
CongUan
  • 3
  • 3
2 Solutions
 
objectsCommented:
you need to scale the graphics context you use to print to.
see the section on nbottom that talks about units of measurement

http://www.javaworld.com/javaworld/jw-10-2000/jw-1020-print.html
0
 
CongUanAuthor Commented:
Hi,
Scaling image is not good in this case, It maybe have problem with the image,

As the java.awt.PrintJob I know that we can set the print resolution by the below code
     //set resoltion for print
    java.awt.PageAttributes pa= new PageAttributes();
    pa.setPrinterResolution(600);
    // get printer job
    java.awt.PrintJob pj=Toolkit.getDefaultToolkit().getPrintJob(this,"My Printing",null,pa);

But I have not used. I used java.awt.Print.PrintJob to develop,
So, do we have any way to do with java.awt.Print.PrintJob for setting the resolution?

Thank again!
0
 
objectsCommented:
not the image, the graphics context you are printing to.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
CongUanAuthor Commented:
Hi,
I am not clearly about your mention, what is graphics context related here?


Tx!
0
 
objectsCommented:
The Graphics instance passed to your print() method.
0
 
CongUanAuthor Commented:
Thank hoomany,
It is very helpful for me!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now