JDK-8019880 : Characters overlapping during Print with Java 7
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7u25
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • Submitted: 2013-07-03
  • Updated: 2013-07-08
  • Resolved: 2013-07-08
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_25 " 
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
Printing with Java 7 overlaps characters. In Java 6, it was working properly.

We use Applet to support Online printing. Before java 7, the feature was working properly. Now on JRE7 we are facing problem of character overlapping.

Printer: Dot Matrix
Manf:    Epson, TVS

REGRESSION.  Last worked in version 6

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On JRE7, just print a page having more than one line.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Characters of each line gets overlapped to each other. Not readable.
ACTUAL -
Should not be overlap as works in JRE6. Should be readable.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.UIManager;

public class HelloWorldPrinter implements Printable, ActionListener {

    public int print(Graphics g, PageFormat pf, int page) throws PrinterException {

        if (page > 0) { /* We have only one page, and 'page' is zero-based */
            return NO_SUCH_PAGE;
        }

        /*
         * User (0,0) is typically outside the imageable area, so we must
         * translate by the X and Y values in the PageFormat to avoid clipping
         */
        Graphics2D g2d = (Graphics2D) g;
        g2d.translate(pf.getImageableX(), pf.getImageableY());

        /* Now we perform our rendering */
        g.drawString( " Hello world! " , 100, 100);

        /* tell the caller that this page is part of the printed document */
        return PAGE_EXISTS;
    }

    public void actionPerformed(ActionEvent e) {
        PrinterJob job = PrinterJob.getPrinterJob();
        job.setPrintable(this);
        boolean ok = job.printDialog();
        if (ok) {
            try {
                job.print();
            } catch (PrinterException ex) {
                /* The job did not successfully complete */
            }
        }
    }

    public static void main(String args[]) {

        UIManager.put( " swing.boldMetal " , Boolean.FALSE);
        JFrame f = new JFrame( " Hello World Printer " );
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        JButton printButton = new JButton( " Print Hello World " );
        printButton.addActionListener(new HelloWorldPrinter());
        f.add( " Center " , printButton);
        f.pack();
        f.setVisible(true);
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Image Printing or use JRE6