Skip to content

Commit 3af01b6

Browse files
committed
Re-enable PDF macOS attributes for Java 8u152+
Closes qzind#174
1 parent b3ccc91 commit 3af01b6

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/java-semver-0.9.0.jar

45.7 KB
Binary file not shown.

src/qz/common/Constants.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package qz.common;
22

3+
import com.github.zafarkhaja.semver.Version;
4+
35
import java.awt.*;
46

57
/**
@@ -9,7 +11,8 @@ public class Constants {
911
public static final String HEXES = "0123456789ABCDEF";
1012
public static final char[] HEXES_ARRAY = HEXES.toCharArray();
1113
public static final int BYTE_BUFFER_SIZE = 8192;
12-
public static final String VERSION = "2.0.3";
14+
public static final Version VERSION = Version.valueOf("2.0.3");
15+
public static final Version JAVA_VERSION = Version.valueOf(System.getProperty("java.version").replaceFirst("_", "-"));
1316

1417
/* QZ-Tray Constants */
1518
public static final String BLOCK_FILE = "blocked";

src/qz/printer/action/PrintPDF.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package qz.printer.action;
22

3+
import com.github.zafarkhaja.semver.Version;
34
import net.sourceforge.iharder.Base64;
45
import org.apache.pdfbox.io.IOUtils;
56
import org.apache.pdfbox.pdmodel.PDDocument;
@@ -89,8 +90,9 @@ public void print(PrintOutput output, PrintOptions options) throws PrinterExcept
8990
PrintOptions.Pixel pxlOpts = options.getPixelOptions();
9091
PrintRequestAttributeSet attributes = applyDefaultSettings(pxlOpts, page);
9192

92-
if (SystemUtilities.isMac()) {
93-
log.warn("OSX cannot use attributes with PDF prints, disabling");
93+
// Disable attributes per https://github.com/qzind/tray/issues/174
94+
if (SystemUtilities.isMac() && Constants.JAVA_VERSION.lessThan(Version.valueOf("1.8.0-152"))) {
95+
log.warn("MacOS and Java < 8u152 cannot use attributes with PDF prints, disabling");
9496
attributes.clear();
9597
}
9698

0 commit comments

Comments
 (0)