• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing a formatted file

 
gov kur
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Evertybody,
I need to write strings to a txt file in a formatted manner. for e.g.

---------------
| NAME | ID |
---------------
| JACK | JA |
| iiii | ii |
| qqqq | qq |
---------------

If this text is seen in Notepad and the font selected is Courier then the alignment is maintained as all charecters are of same width in Courier. However if the font changes the alignment goes for a toss(as can be seen here). Now in my case the strings are in a regional language the fonts of which can never be of same width.
so how can i maintain this formatting i need? writing the file in Character mode won't help me as the characters sizes in terms of pixels are different.
Is is possible to specify that "a particular column should start writing from say... pixel no. 300" ?

Please help me
[ December 26, 2005: Message edited by: gov kur ]
 
Paul Clapham
Sheriff
Posts: 21876
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it isn't possible. Text files do not contain any formatting information like font selection.
 
gov kur
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
guess i was expecting that
but would it be possible to generate a image or a pdf that could help me achieve the same result ? ... i am not too familiar with image/pfd generation. My end target is to be able to generate printouts of the formatted information.
 
Satish Chilukuri
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to put your data into a table structure. Excel would be a good choice for that. JExcel is a good tool for java based excel generation. If you want the data in a pdf format, have a look at iText API. Here also you can have data formatted in a table. Effort wise, IMO, both approaches would cost you the same.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!