Let me first describe the picture below:
- There are two printed articles. The only difference between the two is that several βout of paperβ characters on the left are replaced by a dot β.β. character in the document on the right.
- The red line represents the left border to which the text should be aligned
- The green curve represents my intention to align all the characters that it connects into one column. In fact, the green curve should be vertical.

I want all characters highlighted in green to be printed in one column.
The font of the string is Monospaced Courier New. However, whitespace does not seem to print as monospaced (see "Dotted" lines against lines with space characters at the beginning).
To print the line, I use the standard Java print service API on top of the JTextPane component:
PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPrintable(myTextPane); pj.print();
To my knowledge, the Java print service API actually calls the paint () methods of myTextPane. Therefore, the preview should look exactly like the print version of String.
However, it is not. The preview seems to misinterpret the characters of the monospace space (see last image). The preview looks exactly the way I want the text to print.

Any suggestions on how to get the JavaPrintServiceAPI to correctly print monospaced space characters?
source share