JDK-8307246 : Printing: banded raster path doesn't account for device offset values
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8,17.0.6
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2023-04-29
  • Updated: 2024-02-27
  • Resolved: 2024-02-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23 b11Fixed
Description
ADDITIONAL SYSTEM INFORMATION :
OS: Windows 10 and earlier
Java: 17.0.6

A DESCRIPTION OF THE PROBLEM :
There are 3 elements (rectangle, left line, bottom line) painted on imageable area in the same way. But Java Print Service draws them differently depends on some conditions.
When is using alpha value less than 255 and page orientation is set to LANDSCAPE only rectangle is painted on the paper though all 3 figures must be drawn. 
When I replace alpha value to 255 in the ((Graphics2D)graphics).setPaint(new java.awt.Color(0,0,0,100)) everything works well. 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile and run the code below

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Rectangle, left line, bottom line is painted
ACTUAL -
Rectangle is painted

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.print.*;

public class Printing implements Printable {
    private static Paper paper;
    @Override
    public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
        if (Thread.interrupted())
        {
            throw new PrinterException("Current thread interrupted.");
        }

        Stroke oldstroke = ((Graphics2D)graphics).getStroke();
        ((Graphics2D)graphics).setStroke(new BasicStroke(10));
        ((Graphics2D)graphics).translate(15, 0);
        graphics.drawLine(0,0,0,300); //LEFT margin line
        ((Graphics2D)graphics).translate(-15, 0);

        ((Graphics2D)graphics).translate(0, -15);
        graphics.drawLine(0,(int)paper.getImageableWidth(),300,(int)paper.getImageableWidth());//BOTTOM margin line
        ((Graphics2D)graphics).translate(0, 15);
        ((Graphics2D)graphics).setStroke(oldstroke);

        ((Graphics2D)graphics).setPaint(new java.awt.Color(0,0,0,100));
        ((Graphics2D)graphics).fill(new Rectangle(0,0,200,200));


        return Printable.PAGE_EXISTS;
    }

    public static void main(String[] argv) {
        Printing printer = new Printing();
        PrinterJob printJob = PrinterJob.getPrinterJob();
        PageFormat pageFormat = printJob.defaultPage();
        paper = pageFormat.getPaper();
        paper.setImageableArea(0,0,paper.getWidth(),paper.getHeight());
        pageFormat.setOrientation(PageFormat.LANDSCAPE);
        pageFormat.setPaper(paper);

        Book book = new Book();
        book.append(printer, pageFormat,1);
        printJob.setPageable(book);
        try {
            printJob.print();
        } catch (PrinterException e) {
            e.printStackTrace();
        }

    }
}

---------- END SOURCE ----------

FREQUENCY : always



Comments
Changeset: 56c50841 Author: vtstydev <vtsty.dev@gmail.com> Committer: Alexey Ivanov <aivanov@openjdk.org> Date: 2024-02-19 13:15:13 +0000 URL: https://git.openjdk.org/jdk/commit/56c50841ee1d4382203e200e9b9c803ee6021097
19-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17030 Date: 2023-12-08 05:52:46 +0000
08-12-2023

I tested in Xerox AltaLink B8155 printer and I am able to reproduce non-rendering of all contents (only rectangle is shown) even in JDK8GA Additionally, in my Microsoft-Print-to-pdf setting, I am not able to see any contents actually.
22-05-2023

[~psadhukhan] When the page to be printed is saved as pdf all the contents are seen - rectangle, left and bottom line on both jdk17 LTS and 21. But since it is mentioned that this issue occurs specifically with a printer setup/when printed, it needs to be investigated with printer setup.
19-05-2023

Additional Information from submitter: ============================ Here are the photos <attached photos> 1.jpg : 2 elements output, without rectangle painting. public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (Thread.interrupted()) { throw new PrinterException("Current thread interrupted."); } Stroke oldstroke = ((Graphics2D)graphics).getStroke(); ((Graphics2D)graphics).setStroke(new BasicStroke(10)); ((Graphics2D)graphics).translate(15, 0); graphics.drawLine(0,0,0,300); //LEFT margin line ((Graphics2D)graphics).translate(-15, 0); ((Graphics2D)graphics).translate(0, -15); graphics.drawLine(0,(int)paper.getImageableWidth(),300,(int)paper.getImageableWidth());//BOTTOM margin line ((Graphics2D)graphics).translate(0, 15); ((Graphics2D)graphics).setStroke(oldstroke); /* ((Graphics2D)graphics).setPaint(new java.awt.Color(0,0,0,100)); ((Graphics2D)graphics).fill(new Rectangle(0,0,200,200)); */ return Printable.PAGE_EXISTS; } 2.jpg : 3 elements output. Rectangle color has alpha = 255. public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (Thread.interrupted()) { throw new PrinterException("Current thread interrupted."); } Stroke oldstroke = ((Graphics2D)graphics).getStroke(); ((Graphics2D)graphics).setStroke(new BasicStroke(10)); ((Graphics2D)graphics).translate(15, 0); graphics.drawLine(0,0,0,300); //LEFT margin line ((Graphics2D)graphics).translate(-15, 0); ((Graphics2D)graphics).translate(0, -15); graphics.drawLine(0,(int)paper.getImageableWidth(),300,(int)paper.getImageableWidth());//BOTTOM margin line ((Graphics2D)graphics).translate(0, 15); ((Graphics2D)graphics).setStroke(oldstroke); ((Graphics2D)graphics).setPaint(new java.awt.Color(0,0,0,255)); ((Graphics2D)graphics).fill(new Rectangle(0,0,200,200)); return Printable.PAGE_EXISTS; } 3.jpg : 1 element output. Rectangle color has alpha = 100 public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (Thread.interrupted()) { throw new PrinterException("Current thread interrupted."); } Stroke oldstroke = ((Graphics2D)graphics).getStroke(); ((Graphics2D)graphics).setStroke(new BasicStroke(10)); ((Graphics2D)graphics).translate(15, 0); graphics.drawLine(0,0,0,300); //LEFT margin line ((Graphics2D)graphics).translate(-15, 0); ((Graphics2D)graphics).translate(0, -15); graphics.drawLine(0,(int)paper.getImageableWidth(),300,(int)paper.getImageableWidth());//BOTTOM margin line ((Graphics2D)graphics).translate(0, 15); ((Graphics2D)graphics).setStroke(oldstroke); ((Graphics2D)graphics).setPaint(new java.awt.Color(0,0,0,100)); ((Graphics2D)graphics).fill(new Rectangle(0,0,200,200)); return Printable.PAGE_EXISTS; }
16-05-2023

Issue to be reviewed on printing with printer/copier.
04-05-2023

Additional information from submitter: ============================ This bug occurs only when a real printer paints graphics on real paper.
04-05-2023

Checked with attached testcase in Windows 10, Issue is not reproducible with Printer Setting to default(Microsoft Print to PDF)<attached pdf> Mail to submitter ============= Please share output (sample pdf) of the provided testcase.
02-05-2023