-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P4
-
None
-
Affects Version/s: 17, 21, 25
-
Component/s: client-libs
-
None
-
linux, os_x
When using landscape paper (the paper width > the paper height), the printed content is cut off on Linux and Mac.
Two places were found where the defect may occur:
- CustomMediaSizeName class
- native code on macOS
The MediaSize cannot be created when the paper width > the paper height, in this case the paper is rotated but the MediaPrintableArea stays the same.
This means that a paper 4x2'' with imageable area 4x2'' will be stored as a 2x4'' paper with the imageable area 4x2''. The printable area is an intersection of the paper size and the imageable area and its size is 2x2''.
CUPSPrinter.java:
//The paper is rotated if the width more than the length in the CustomMediaSizeName.create method.
msn = CustomMediaSizeName.create(media[i*2], media[i*2+1],
width, length);
.....
// The MediaPrintableArea is not rotated if the width more than the length
mpa = new MediaPrintableArea(x, y, w, h,
MediaPrintableArea.INCH);
The macOS native code does not select necessary device paper, it just sets the paper size in user space (NSPrintInfo setPaperSize) that may be mapped to an incorrect device paper.
Code from the CPrinterJob.m:
jdouble jPhysicalWidth = (*env)->CallDoubleMethod(env, src, jm_getWidth); // AWT_THREADING Safe (!appKit)
CHECK_EXCEPTION();
jdouble jPhysicalHeight = (*env)->CallDoubleMethod(env, src, jm_getHeight); // AWT_THREADING Safe (!appKit)
CHECK_EXCEPTION();
[dst setPaperSize:NSMakeSize(jPhysicalWidth, jPhysicalHeight)];
A reproducer (ImageCutOff.java) is attached. A PDF printer may be used to reproduce the problem. It is required to add the following 4 new lines to the test printer's PPD file. Then select the test printer as the system default.
*PageSize w288h144/4.00x2.00": "<</PageSize[288 144]/ImagingBBox null>>setpagedevice"
*PageRegion w288h144/4.00x2.00": "<</PageSize[288 144]/ImagingBBox null>>setpagedevice"
*ImageableArea w288h144/4.00x2.00": "0 0 288 144"
*PaperDimension w288h144/4.00x2.00": "288 144"
The test creates and prints a BufferedImage with a black rectangle along the edges, a line from the top left corner to the bottom right corner, a line from the bottom left corner to the top right corner and a line from the left to the right side.
Expected result: whole image is printed.
Actual result: the image is cut off.
Two places were found where the defect may occur:
- CustomMediaSizeName class
- native code on macOS
The MediaSize cannot be created when the paper width > the paper height, in this case the paper is rotated but the MediaPrintableArea stays the same.
This means that a paper 4x2'' with imageable area 4x2'' will be stored as a 2x4'' paper with the imageable area 4x2''. The printable area is an intersection of the paper size and the imageable area and its size is 2x2''.
CUPSPrinter.java:
//The paper is rotated if the width more than the length in the CustomMediaSizeName.create method.
msn = CustomMediaSizeName.create(media[i*2], media[i*2+1],
width, length);
.....
// The MediaPrintableArea is not rotated if the width more than the length
mpa = new MediaPrintableArea(x, y, w, h,
MediaPrintableArea.INCH);
The macOS native code does not select necessary device paper, it just sets the paper size in user space (NSPrintInfo setPaperSize) that may be mapped to an incorrect device paper.
Code from the CPrinterJob.m:
jdouble jPhysicalWidth = (*env)->CallDoubleMethod(env, src, jm_getWidth); // AWT_THREADING Safe (!appKit)
CHECK_EXCEPTION();
jdouble jPhysicalHeight = (*env)->CallDoubleMethod(env, src, jm_getHeight); // AWT_THREADING Safe (!appKit)
CHECK_EXCEPTION();
[dst setPaperSize:NSMakeSize(jPhysicalWidth, jPhysicalHeight)];
A reproducer (ImageCutOff.java) is attached. A PDF printer may be used to reproduce the problem. It is required to add the following 4 new lines to the test printer's PPD file. Then select the test printer as the system default.
*PageSize w288h144/4.00x2.00": "<</PageSize[288 144]/ImagingBBox null>>setpagedevice"
*PageRegion w288h144/4.00x2.00": "<</PageSize[288 144]/ImagingBBox null>>setpagedevice"
*ImageableArea w288h144/4.00x2.00": "0 0 288 144"
*PaperDimension w288h144/4.00x2.00": "288 144"
The test creates and prints a BufferedImage with a black rectangle along the edges, a line from the top left corner to the bottom right corner, a line from the bottom left corner to the top right corner and a line from the left to the right side.
Expected result: whole image is printed.
Actual result: the image is cut off.