Recently we have had a request to allow auto rotation of printed pdf pages without centering them within the print pages imageable area. This was an easy enough task to achieve but has made some changes I thought it wise to write about so as to give a little more detail.
The first and most important change to mention is the removal of a public variable. The variable isAutoRotateAndCenter within SwingPrinter has been completely removed. This variable was a flag that allowed the page to be both rotated and centered, as we are split this functionality we now need two flags, one for each.
In place of isAutoRotateAndCenter we now have two flags which can be controlled using SwingPrinter.setAutoRotate(boolean) and SwingPrinter.setCenterOnScaling(boolean).
On top of this I have also added a new method to the PdfDecoder so we have a complete set of methods in this class to alter the rotation and centering of the printer page.
PdfDecoder.setPrintAutoRotate(boolean) sets a flag to control if the page should auto rotate to best fit the printed page imageable area.
PdfDecoder.setCenterOnScaling(boolean) sets a flag to control if center the page within the printed page imageable area.
PdfDecoder.setPrintAutoRotateAndCenter(boolean) sets the flags to control if the page should auto rotate to best fit the printed page imageable area and center it within the imageable area.
That’s it, there aren’t many changes in this one but as it has resulted in the removal of a public variable we thought it would be best to post something.
This post is part of our “Printing Articles Index” in these articles, we aim to help you understand printing in Java and PDF’s.
Latest posts by Kieran France (see all)
- Improved Shape Rendering with Soft Clipping - August 24, 2017
- 4 Hidden Features in Java 9 - May 30, 2017
- Why HTTP/2 Client in Java 9 is important - May 23, 2017
- PDF Portfolio support added to JPedal, so what are they? - April 4, 2017
- Our Goals for the JPedal Java PDF Library SDK in 2017 - December 16, 2016