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.
Are you a Developer working with PDF files?
Our developers guide contains a large number of technical posts to help you understand the PDF file Format.
Find out more about our software for Developers
|Convert PDF to HTML5 or SVG|
|Convert AcroForms and XFA to HTML5|
|Java PDF SDK for working with PDF files|