Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
eric zhao
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, Charles. I will try it out.
 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic