Puzzles with printed output
From: Jonathan Sachs (llm040903_at_earthlink.net)
Date: 09/05/04
- Next message: Paul Lutus: "Re: Puzzles with printed output"
- Previous message: Tor Iver Wilhelmsen: "Re: JTable problems"
- Next in thread: Paul Lutus: "Re: Puzzles with printed output"
- Reply: Paul Lutus: "Re: Puzzles with printed output"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 05 Sep 2004 12:46:15 GMT
I'm working with printing from a subclass of JTextPane. The printing has
uncovered some aspects of Swing behavior that are puzzling, and in at least
one respect, plain wrong. I'm seeking information about what is
happening and how I can make my output print correctly.
I am currently using JBuilder 5 with JDK 1.3.0. (I intend to upgrade when
JBuilder 2005 is released.) The operating system is Windows XP.
This is my first experiment with printing in Swing, but I don't think I'm
doing anything unusual. I define attributes by creating SimpleAttributeSet
objects and setting attributes with the StyleConstants "set..." methods.
Then I pass a SimpleAttributeSet object to the document's insertString
method with each piece of text. I am currently using Times New Roman
10-point type, but I had similar problems with Swing's built-in Serif font.
My extension to JTextPane implements Printable, and defines a print method
that is copied directly from an example I found on the Web. The menu's Print
command creates a PrinterJob and a Book, and uses them to print the document
without trying to do anything fancy.
On the screen, the Times New Roman font looks like a different family from
the same font displayed in a Microsoft Word window. The line height is
right, but the x-height is smaller, making the font almost unreadable in
this size.
In print, the font appears to be of the right family (the x-height is the
same as in printed output from Word), but it appears to be bold, although I
did not set the "bold" attribute. I have tried turning the bold attribute
both off and on. Turning it off has no effect. Turning it on makes the
displayed text look bold, but has no effect on the printed text.
Line spacing on the screen is the same as in Word (with Word's line spacing
set to "single"). Line spacing in print is considerably wider; Word prints
exactly six lines per inch, while my application prints about 5.5. I have
tried explicitly setting line spacing to zero, with no effect.
Some of the text my application displays is intentionally underlined or
struck out. On the screen the underlines and strikeouts are correct. In
print they are all about 5% too short when I try to print regular
characters, and about 5% too long when I try to print bold characters.
- Next message: Paul Lutus: "Re: Puzzles with printed output"
- Previous message: Tor Iver Wilhelmsen: "Re: JTable problems"
- Next in thread: Paul Lutus: "Re: Puzzles with printed output"
- Reply: Paul Lutus: "Re: Puzzles with printed output"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|