• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

printing rtf from jEditorPane

 
Sancho Xavier
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello there,

I have developed an app that uses freemarker to load .rtf templates, insert text entered through a gui featuring numerous jTextFields into these templates, spit out a new .rtf file as well as load the new .rtf file into a jEditorPane (set to text/rtf) and finally print the jEditorPane. everything runs smoothly, save the printing part. the printed output does not match the contents of the jEditorPane (or the .rtf file itself) as closely as it should. for some reason the font is different and larger, and the spacing is off. i am not really certain what is going on here, but I have used this print class to enable the printing of a jEditorPane. if anyone has any clues as to why the printed version does not match the contents of the jEditorPane (it is rendered perfectly here...), i would be very greatful for your help.

Sancho
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There could be DPI difference between screen and printer device that's why font size is different. Not sure about this "the spacing is off" what does it mean?

You can also try to use something like this
http://java-sl.com/JEditorPanePrinter.html
to preview and see what's the difference with printed page.

may be the problem is difference in printed page width and JEditorPane width.

Regards,
Stas
 
Sancho Xavier
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i have since switched to a different printing class as seen here... and the problem is only slightly better. i am pretty sure that the problem lies in correctly specifying the margins, as when i print, the text is larger, the indents, spaces, etc are all out of whack, and text tends to be cut off in mid letter on the right side of the page. i have sent the rtf data to a jEditorPane with the size 504, 684 (which is an educated guess as to the size of a page with .5 inch margins...) and while the rtf data continues to show correctly in the jEditorPane, the printed version and the print preview are chopped. any help is greatly appreciated, printing in java seems so difficult!
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a guess about DPI difference. Could you measure your printed output? I guess it's ~33% bigger than necessary.
By default windows DPI is 96 but all printers are based to have 72 pixels.

You cna try to correct this but scale the printer graphics
g.scale(0.75, 0.75); // 72/96

Regards,
Stas
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic