Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (778)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Generate RTF files  (Read 3929 times)
0 Members and 1 Guest are viewing this topic.
Offline Marvin Fröhlich

Senior Devvie




May the 4th, be with you...


« Posted 2010-04-09 15:52:00 »

Hey guys,

can anyone tell me, how to generate RTF files? iText dropped support for this format. And it looks like you can handle RTF files with pure Java. I found the RTFEditorKit. But I couldn't find any good documentation, that actually tells me, how to use it. I would like to use it as follows.

- Create the document
- add styled text (left/center/right/justify aligned, bold, italic, underlined, font, colors)
- insert page brakes
- read current page number

I don't know, if RTF supports page headers and footers. If it does, I would like to add them, too.

What is the best way to do this?

Marvin
Offline Mr_Light

Senior Devvie


Medals: 1


shiny.


« Reply #1 - Posted 2010-04-09 16:07:03 »

Better stop myself from typing a bunch of stuff and ask the most important question,

Why (the hell) would you need RTF in this day and age?

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #2 - Posted 2010-04-09 16:40:50 »

RTF Wiki
There is a list of links to the specifications for the various versions near the bottom.
I used a subset of it once years ago as an export format, but you can do so much layout with HTML these days, it's difficult to see the need to carry on with RTF.  Only a subset is defined in Java and apparently not very well.
Java RTF Bug Report
Another bug report listing not-implemented features

I think headers and footers are not supported.

Time flies like a bird. Fruit flies like a banana.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Marvin Fröhlich

Senior Devvie




May the 4th, be with you...


« Reply #3 - Posted 2010-04-09 16:56:03 »

Thanks for the answers.

Why (the hell) would you need RTF in this day and age?

We want to provide a report download in a web application which can be directly opened with M$ Word (yes, I know Wink). And we don't want to use PIO (for this).

RTF Wiki
There is a list of links to the specifications for the various versions near the bottom.

Do you suggest to create the RTF source directly? Well this might be doable. But this really should be done behind the scenes on a nice API.

Marvin
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #4 - Posted 2010-04-09 18:47:11 »

Do you suggest to create the RTF source directly? Well this might be doable. But this really should be done behind the scenes on a nice API.

If the export format doesn't have to be WYSIWYG...
I'd be tempted to generate a report template in word, with tag's where the content should go, save that as RTF and use it as a template.  If the report format is fixed and you just need to put text into it, this is easy.  If you need to dynamically generate tables, there's a bit more work, especially to control layout.
You will still need to escape special characters of course.

Time flies like a bird. Fruit flies like a banana.
Offline Marvin Fröhlich

Senior Devvie




May the 4th, be with you...


« Reply #5 - Posted 2010-04-09 22:25:08 »

No, nothing about WYSIWYG. I want to generate the RTF purely through coding. And I cannot use a template. I really only need to do, what I scatched up above.

Marvin
Offline pjt33

« JGO Spiffy Duke »


Medals: 40
Projects: 4
Exp: 7 years



« Reply #6 - Posted 2010-04-09 22:44:32 »

We want to provide a report download in a web application which can be directly opened with M$ Word (yes, I know Wink).
A cunning tip I picked up from someone is that if you name an HTML file with a .doc extension then Word will happily open it. Of course, HTML doesn't include syntax for headers and footers.
Offline Mr_Light

Senior Devvie


Medals: 1


shiny.


« Reply #7 - Posted 2010-04-10 00:43:58 »

Thanks for the answers.

We want to provide a report download in a web application which can be directly opened with M$ Word (yes, I know Wink). And we don't want to use PIO (for this).

There's as noted, html, pdf (but I take it open in word means open and edit it) and we have ODF and ooxml of which there should be api's around,
http://www.javadocx.com/features which lists an lgpl version (no idea about the quality)

and as mentioned taking a premade document and adding some string replace sprikles also works wonders

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (349 views)
2018-11-16 13:46:03

hadezbladez (183 views)
2018-11-16 13:41:33

hadezbladez (349 views)
2018-11-16 13:35:35

hadezbladez (85 views)
2018-11-16 13:32:03

EgonOlsen (2179 views)
2018-06-10 19:43:48

EgonOlsen (2221 views)
2018-06-10 19:43:44

EgonOlsen (1379 views)
2018-06-10 19:43:20

DesertCoockie (2012 views)
2018-05-13 18:23:11

nelsongames (1670 views)
2018-04-24 18:15:36

nelsongames (2309 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!