Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8040620

Overlapping of Japanese characters with the PrinterJob

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 7u21
    • client-libs
    • 2d
    • windows_7

      FULL PRODUCT VERSION :
      java version " 1.7.0_21 "
      Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
      Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Since Java 1.7 we have problems to print Japanese characters using the java.awt.print.PrinterJob if the String contains both Japanese characters and digits, the characters overlaps.

      REGRESSION. Last worked in version 6u45

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the code below

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Printing on default printer with no overlapping characters
      ACTUAL -
      Printing on default printer with overlapping characters

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Graphics;
      import java.awt.print.Book;
      import java.awt.print.PageFormat;
      import java.awt.print.Printable;
      import java.awt.print.PrinterException;
      import java.awt.print.PrinterJob;

      import javax.print.PrintService;
      import javax.print.PrintServiceLookup;

      /**
       * This class prints a String containing Japanese characters and numbers
       *
       * in Java 1.6 the String is correctly printed
       * in Java 1.7 we have an overlapping of the Japanese characters
       *
       */
      public class PrintTest {

      /**
       * @param args no args
       * @throws PrinterException
       */
      public static void main(String[] args) throws PrinterException {

      // Get the default printer
      PrintService printService = PrintServiceLookup.lookupDefaultPrintService();

      // Create a new Job
      PrinterJob job = PrinterJob.getPrinterJob();
      job.setPrintService(printService);

      // Create a new printable with Japanese characters
      Printable page = new Printable() {

      @Override
      public int print(Graphics graphics, PageFormat pageFormat,
      int pageIndex) throws PrinterException {

      // Please note that there is a number in the middle of the string
      graphics.drawString( " ???8???? " , 100, 100);

      return 0;
      }

      };

      // Create a book and print it
      Book book = new Book();
      PageFormat pageFormat = new PageFormat();
      book.append(page, pageFormat);
      job.setPageable(book);

      job.print();
      }


      }


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

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: