This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing document with Javax.Print package problem.  RSS feed

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can get the document to print, but it prints the text separated by "\n" on separate lines but tabbed over. Like so:

Line 1
------Line 2
-------------Line 3

etc..

I've tried to replace the "\n" with "\r", but that just makes the lines print on top of each other.
I replaced (char)13 with (char)10 and it did the same thing.

These are .txt files I'm writing to and then trying to print.

Has anyone else ever had this problem before?

Thanks

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need both - \r to return to the start of the line, and \n to advance to the next line. Problem is, only text files created on Windows have both characters; files created on UNIX-ish systems only have the newline. So you may have to replace all occurrences of \r by \r\n.
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool, I replaced '\n' with '\r\n' and it worked great : ).

Thanks
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!