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

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

How to set Margins when print with JAVA

Hi Experts,
I need to set page format Margins as below
 TopMargins=1
 LeftMargins=0
 RightMargins=0
 BottonMargins=1
 Gutter=0
I have not used PageDialog to set this, just want set this in the code not use pageFormat = printJob.pageDialog(pageFormat);

But I don't know how to set this wiht PageFormat object in code JAVA.

Please let help me with this.

Thanks in advance!
0
CongUan
Asked:
CongUan
  • 4
  • 3
2 Solutions
 
hoomanvCommented:
java.awt.print.Paper.setImageableArea(double x, double y, double width, double height) could be a solution
because PageFormat will get the page coordinate info from the Paper object associated to it
0
 
hoomanvCommented:
and then pageFormat.setPaper(yourCustomizedPaper)
0
 
WebstormCommented:
also use Paper.getHeight() .getWidth() to call setImageableArea
default margins are 1 inch (72pt)
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:
Yah, Thanks very much.
0
 
hoomanvCommented:
CongUan ... how come you didn't select my answer which was first and the same as Webstorm
http://www.experts-exchange.com/help.jsp#hi68
0
 
WebstormCommented:
>> the same as Webstorm
Where did you give those url ?
But i agree you should have received points (maybe a split), and wit h A-grade.
0
 
hoomanvCommented:
the main solution with needed steps was provided by me
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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