• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

printing rtf from jEditorPane

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic