Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8343224: print/Dialog/PaperSizeError.java fails with MediaSizeName is not A4: A4 #11

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -203,16 +203,17 @@ public static CustomMediaSizeName create(String name, String choice,
if (value == null) {
value = new CustomMediaSizeName(name, choice, width, length);
customMap.put(key, value);

// add this new custom media size name to MediaSize array
if ((width > 0.0) && (length > 0.0)) {
try {
new MediaSize(width, length, Size2DSyntax.INCH, value);
} catch (IllegalArgumentException e) {
if (value.getStandardMedia() == null) {
// add this new custom media size name to MediaSize array
if ((width > 0.0) && (length > 0.0)) {
try {
new MediaSize(width, length, Size2DSyntax.INCH, value);
} catch (IllegalArgumentException e) {
/* PDF printer in Linux for Ledger paper causes
"IllegalArgumentException: X dimension > Y dimension".
We rotate based on IPP spec. */
new MediaSize(length, width, Size2DSyntax.INCH, value);
new MediaSize(length, width, Size2DSyntax.INCH, value);
}
}
}
}
Expand Down
18 changes: 12 additions & 6 deletions test/jdk/java/awt/print/Dialog/PaperSizeError.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,16 +23,22 @@

/**
* @test
* @bug 6360339
* @bug 6360339 8343224
* @key printer
* @summary Test for fp error in paper size calculations.
* @run main/manual PaperSizeError
*/

import java.awt.print.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.PrintService;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.Size2DSyntax;
import javax.print.attribute.standard.MediaSize;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.OrientationRequested;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.PrinterJob;

public class PaperSizeError {

Expand Down