Skip to content

Commit 56f1728

Browse files
committed
Fix PDF landscape
- Only rotate if attributes are not set (e.g. MacOS). - Update PDFBOX to 2.0.3 stable - Use 90 degrees for landscape (not 270 degrees) Closes #126
1 parent 2bf75cb commit 56f1728

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed
7.59 MB
Binary file not shown.

src/qz/printer/PrintOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ public int getMediaSizeUnits() {
491491
public enum Orientation {
492492
PORTRAIT(OrientationRequested.PORTRAIT, PageFormat.PORTRAIT, 0),
493493
REVERSE_PORTRAIT(OrientationRequested.PORTRAIT, PageFormat.PORTRAIT, 180),
494-
LANDSCAPE(OrientationRequested.LANDSCAPE, PageFormat.LANDSCAPE, 270),
495-
REVERSE_LANDSCAPE(OrientationRequested.REVERSE_LANDSCAPE, PageFormat.REVERSE_LANDSCAPE, 90);
494+
LANDSCAPE(OrientationRequested.LANDSCAPE, PageFormat.LANDSCAPE, 90),
495+
REVERSE_LANDSCAPE(OrientationRequested.REVERSE_LANDSCAPE, PageFormat.REVERSE_LANDSCAPE, 270);
496496

497497
private final OrientationRequested asAttribute; //OrientationRequested const
498498
private final int asFormat; //PageFormat const

src/qz/printer/action/PrintPDF.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import qz.utils.SystemUtilities;
2222

2323
import javax.print.attribute.PrintRequestAttributeSet;
24+
import javax.print.attribute.standard.OrientationRequested;
2425
import java.awt.geom.AffineTransform;
2526
import java.awt.print.PageFormat;
2627
import java.awt.print.PrinterException;
@@ -106,8 +107,9 @@ public void print(PrintOutput output, PrintOptions options) throws PrinterExcept
106107
rotatePage(doc, pd, pxlOpts.getRotation());
107108
}
108109

109-
//force orientation change at data level
110-
if (pxlOpts.getOrientation() != null && pxlOpts.getOrientation() != PrintOptions.Orientation.PORTRAIT) {
110+
if (!attributes.containsKey(OrientationRequested.class) && pxlOpts.getOrientation() != null &&
111+
pxlOpts.getOrientation() != PrintOptions.Orientation.PORTRAIT) {
112+
//force orientation change at data level
111113
pd.setRotation(pxlOpts.getOrientation().getDegreesRot());
112114
}
113115
}

0 commit comments

Comments
 (0)