import java.awt.BorderLayout; 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.JScrollPane; import javax.swing.SwingUtilities; /** * JDK-8055867: * Some characters not printed correctly in HTML text */ public class JDK8055867 { static String htmlText = "" + "

" + "

" + "

“ITEM

" + "

“ITEM”

" + "

COL “ITEM”

" + "

COLU “ITEM”

" + "

COLUM “ITEM”

" + "

" + "

" + "

“ITEM

" + "

“ITEM”

" + "

COL “ITEM”

" + "

COLU “ITEM”

" + "

COLUM “ITEM”

" + "

Java: " + System.getProperty("java.version") + "

"; private static JEditorPane editorPane; 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.getContentPane().add(printButton, BorderLayout.SOUTH); editorPane = new JEditorPane("text/html", htmlText); f.getContentPane().add(new JScrollPane(editorPane), BorderLayout.CENTER); 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()); 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(); } }); } }