Ok so I'm writing a program that outputs text to a file.

Currently, I am writing it to a .TXT file for ease and convenience. Ideally, I would like to output some of the information so that it is formatted with Italics. I'm thinking that using a RTF file would be simplest but i'm not entirely sure as I have never bothered with this problem.

Any help of guidance would be appriciated. Also if suggesting a file type, do you know of any useful Websites that have tutorials or guides to outputting formatted text using java.

Thank you in advance

Recommended Answers

All 7 Replies

well, you could write to several types of files. you can go for rtf, then this might be a good starting point.
you could also store your layout information in a xml file, and use that template to generate a pdf file, containing the text you want, in the layout you want. XSL Formatting can do that for you.

How about writing your text as an HTML file. That's really easy.

That link is just for controlling layout by automatically inserting blanks - it is not a solution for using italics.

Currently, I am writing it to a .TXT file for ease and convenience. Ideally, I would like to output some of the information so that it is formatted with Italics. I'm thinking that using a RTF file would be simplest but i'm not entirely sure as I have never bothered with this problem.

There are other simpler/lightweight formats out there. For e.g. Markdown, which this site uses for posting is good format if you have modest formatting requirements (italics, underline, bold). Plus it has the advantage of being a format which can be read/viewed without any special viewer (as opposed to RTF files). And if for some reason the users need to view a visual report, there are loads of Markdown to HTML/PDF/XXX converters out there.

I love James Cherrill's idea of using a html file to output. Then the file could be opened ina browser to display the formatting. Never even thought of that. Thank you!!

You're welcome!
J

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.