This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes how to add Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "how to add "page break" in java output file? " Watch "how to add "page break" in java output file? " New topic
Author

how to add "page break" in java output file?

eric zhao
Greenhorn

Joined: Feb 26, 2003
Posts: 20
I have tried to find a way to add page brak or underline those kinds of print control characters in my java output file. However, it seems impossible in ASCII and I didn't find a way in unicode either.
Anyone could help?
Thanks a lot.
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
I've worked with the byte-level (binary) formats of both Word's DOC files, and Rich Text Format (RTF) files.
The simplest way to implement a page break as you would like is to insert unicode character 12, which is a form feed (FF) in ASCII and UTF. This will be interpreted by both Microsoft's Word and the WordPad application that ships with Windows, and a page break will be inserted correctly. You could achieve this in the following code:

However, by not specifying the entire format of a Word document, you may be opening yourself up to some potential problems (including an annoying Word installer dialog), but then I leave that with you...
The alternative is to output the format into a character-set independant format such as RTF, which uses the string "\page" to represent a page-break. Again, you'll need to put in the appropriate headers to avoid any errors.
Let me know if this helps!
[ June 05, 2003: Message edited by: Charles Lyons ]

Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
eric zhao
Greenhorn

Joined: Feb 26, 2003
Posts: 20
Thanks a lot, Charles. I will try it out.
 
GeeCON Prague 2014
 
subject: how to add "page break" in java output file?