Link to home
Start Free TrialLog in
Avatar of gdrnec
gdrnecFlag for United States of America

asked on

Writing RTF/PSW in Java

I need to create an rtf file using very basic java code. The reason the code needs to be basic is that it needs to run on a very cut down jdk and therefore will not be able to leverage the swing classes like the RTFEditorKit or any third party libraries like the one offered by Apache et al.

I seem to be able to create the text that is in an rtf but there seems to be a binary code at the end of the file that appears to be very important and I can't figure out how to write that code into the file.

Lastly, I am really talking about a .psw file that is used for PocketPC Pocket Word and PrintBoy (all PDA). The .psw file looks exactly like an rtf so I believe that if I can crack that nut, I will solve the .psw problem too.

Any help is greatly appreciated.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

I think if you use the lowagie package for pdf, you can write as rtf
e.g.

itext.sourceforge.net/examples/com/lowagie/examples/general/HelloWorldMultiple.java
>>  I need to create an rtf file using very basic java code.

I'm afraid you can't do that completely using the proper APIs for that, and problems like this will probably persist - >>but there seems to be a binary code at the end of the file that appears to be very important.

>> it needs to run on a very cut down jdk and therefore will not be able to leverage the swing classes like the RTFEditorKit or
>> any third party libraries like the one offered by Apache et al

Can we know the details why?
ASKER CERTIFIED SOLUTION
Avatar of Mayank S
Mayank S
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gdrnec

ASKER

Here's the why:

I have a PDA based application written in SW (a java based library for pda) that I need to print from. Unfortunately, the only way I can print from that application is to go through a third party app called PrintBoy (they make wireless adapters for printers to print from a pda). The PrintBoy application will only print a .psw file.

To test that .psw and .rtf are the same thing, I created an rtf on my desktop, changed its extension to .psw, transfered it to my pda and printed successfully. However, when I try to programatically create the .psw/.rtf, PrintBoy throws an error and I believe that the error is the binary code that I am missing from the end of a rtf document.

Does this clarify at all?
Avatar of gdrnec

ASKER

Hi all,

I just tried using the lowagie library and created a quick example rtf. It turns out that there are differences between the .rtf type and the .psw because the lowagie libraries created an rtf that works without any binary codes in it. The binary must be something to do with the .psw file type.

Although I am now abit off topic, does any one know how to write Pocket Word files (.psw). There are extremely close to a rtf but with obviously some differences.

Any help is appreciated
I think you're right as there doesn't seem to be an obvious binary in my simple rtfs
You really need to find the pocket word format. Can't find it myself
Avatar of gdrnec

ASKER

I can't seem to find it either. Maybe I'll have a trawl through MSDN. If you can think of anything else I might check, let me know.

Thanks
Well if that file format is not secret (as far as MS is concerned) i'll be very surprised ;-)
Did you try the open-office API which I posted? It might work. Also see this:

http://encyclopedia.lockergnome.com/s/b/OpenOffice