This commit is contained in:
lifangliang 2025-08-01 13:52:40 +08:00
parent b55b4e87a6
commit 9f2a6e56ff

View File

@ -254,8 +254,8 @@ public class PdfPrinter {
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
// 设置纸张大小
String size = option.getSize() != null ? option.getSize() : "Letter";
aset.add(PAPER_SIZES.getOrDefault(size, MediaSizeName.NA_LETTER));
// String size = option.getSize() != null ? option.getSize() : "Letter";
// aset.add(PAPER_SIZES.getOrDefault(size, MediaSizeName.NA_LETTER));
// 设置颜色模式
setColorMode(aset, option.getColor());
@ -280,7 +280,7 @@ public class PdfPrinter {
* @return PDF页面方向
*/
private static Orientation getPdfOrientation(String orientationStr) {
if (orientationStr != null && "ORI_LANDSCAPE".equalsIgnoreCase(orientationStr)) {
if ("ORI_LANDSCAPE".equalsIgnoreCase(orientationStr)) {
return Orientation.LANDSCAPE;
}
return Orientation.PORTRAIT; // 默认为纵向
@ -293,7 +293,14 @@ public class PdfPrinter {
* @param color 颜色模式字符串
*/
private static void setColorMode(PrintRequestAttributeSet aset, String color) {
if (color != null && ("Full Color".equalsIgnoreCase(color) || "Cover Letter Color Only".equalsIgnoreCase(color))) {
if (color == null) {
aset.add(Chromaticity.MONOCHROME);
return;
}
String c = color.trim().toLowerCase();
if (c.equals("color") || c.equals("full color") || c.equals("cover letter color only")) {
aset.add(Chromaticity.COLOR);
} else {
aset.add(Chromaticity.MONOCHROME);