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

Some characters not printed correctly in HTML text

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • tbd
    • 7, 8, 9
    • client-libs
    • 2d
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.7.0_05"
      Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      When printing HTML text via an editor pane, a "left double quotation mark" character is sometimes printed as a "o grave accent".

      Spacing around the character is sometimes also incorrect.

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start the test program. Click on Print.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The double left quotation mark is printed as a quotation mark and spacing around the character is respected.
      ACTUAL -
      The quotation marks are sometimes printed as accentuated o characters.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.awt.Graphics;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      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.JEditorPane;
      import javax.swing.JFrame;
      import javax.swing.SwingUtilities;

      public class Case65093 {

      static String htmlText = "<html>"
      + "<h3><span style=\" text-decoration: underline;\">&#8220;</span></h3>"
      + "<h3><u>&#8220;</u></h3>"
      + "<h3><u>&#8220;ITEM</u></h3>"
      + "<h3><u>&#8220;ITEM&#8221;</u></h3>"
      + "<h3><u>COL &#8220;ITEM&#8221;</u></h3>"
      + "<h3><u>COLU &#8220;ITEM&#8221;</u></h3>"
      + "<h3><u>COLUM &#8220;ITEM&#8221;</u></h3>"
      + "<p><span style=\" text-decoration: underline;\">&#8220;</span></p>"
      + "<p><u>&#8220;</u></p>"
      + "<p><u>&#8220;ITEM</u></p>"
      + "<p><u>&#8220;ITEM&#8221;</u></p>"
      + "<p><u>COL &#8220;ITEM&#8221;</u></p>"
      + "<p><u>COLU &#8220;ITEM&#8221;</u></p>"
      + "<p><u>COLUM &#8220;ITEM&#8221;</u></p>"
      ;

      private static void createAndShowGUI() {
              JFrame f = new JFrame("Swing Paint Demo");
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.setSize(250,250);
              
              JButton printButton = new JButton("Print");
              printButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
      print();
      }
      });
              f.setContentPane(printButton);
              
              f.setVisible(true);
          }

      private static void print() {
      PrinterJob printerJob = PrinterJob.getPrinterJob();
      printerJob.setPrintable(new Printable() {

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

      graphics.translate((int)pageFormat.getImageableX(), (int)pageFormat.getImageableY());
      graphics.drawLine(0, 0, (int)pageFormat.getWidth(), (int)pageFormat.getHeight());

      JEditorPane editorPane = new JEditorPane("text/html", htmlText);
      editorPane.setSize((int)pageFormat.getImageableWidth(), (int)pageFormat.getImageableHeight());

      editorPane.print(graphics);

      return pageIndex == 0 ? PAGE_EXISTS : NO_SUCH_PAGE;
      }

      });
      try {
      printerJob.print();
      } catch (PrinterException e) {
      e.printStackTrace();
      }
      }

      public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
                  @Override
      public void run() {
                      createAndShowGUI();
                  }
              });
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use Java 6 instead of Java 7.

            psadhukhan Prasanta Sadhukhan
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: