我正在尝试在595px x 425px的纸张上打印JFrame。我这样做有问题。
我可以正确的方式打印它,但是结果旋转了90度。如果我不需要将横向打印纸放在打印机上,就不会有问题。
#one, #two{
height: 150px;
width: 250px;
text-align: center;
}
#one{
background: red;
color: white;
}
#two{
margin: 50px 0;
background: blue;
color: white;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90eg);
}
<div id="one">Need this result</div>
<div id="two">have this result</div>
PageFormat pf = job.defaultPage();
Paper paper = pf.getPaper();
//paper.setSize(595.0, 425.0); this is the correct paper size, but doesnt work if width > height.
paper.setSize(425.0, 595.0);
paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
pf.setOrientation(PageFormat.LANDSCAPE);
pf.setPaper(paper);