• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Problems printing text in JTextPane

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to print text from a JTextPane and can only get a blank page or a single line. Below is the code I am using. This code produces the blank page.

If is use g2D.drawString(getText(), x, y), then my application prints one line of text from the JTextPane and ignores the newline characters. What am I doing wrong? How should I go about this? I decided to use a JTextPane since I will need to print HTML documents and the JTextPane can render this for me.
Thanks,
Steve
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
drawString() is NOT a text processing method, it just paints a picture of the text - on a single line. To do multiple lines you would need to break the string up into lines and paint each line separately.
Printing API: A Tutorial
 
This tiny ad is suggesting that maybe she should go play in traffic.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!