Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with RTF Tables

843804Feb 13 2002 — edited Jun 18 2009
Problem Statement:
1) I am writting a RTF editor. I cant display tables properly in JTextPane. Does anyone have any idea??
2) Find and replace also dosnt work in these tables.
3) Once i save the document through my RTF editor, the tables information just goes away.
4) Word(XP-version) RTF files doesnt work with the RTFEditorKit. I saw a few posts from which I understand that RTF2002 has some elements which is not supported by RTFEditorKit. Is this true?

Given:
Lang: JDK1.3
OS: Win2k

Below is a piece of my code...

m_monitor = new JTextPane();
m_kit = new RTFEditorKit();
m_monitor.setEditorKit(m_kit);
m_context = new StyleContext();
m_doc = new DefaultStyledDocument(m_context);
m_monitor.setDocument(m_doc);


Thankx in advance
Please help
Subhro.

Comments

843804
I am also writing a RTF editor:-)
RTFEditorKit and RTFDocument does't work correctly.
You can't save the pictures, tables and so on.
I owerride standart RTFDocument, RTFEditorKit, ViewFactory and some views.

I implements new RTFWriter (Word2000 compatible).
With tables and nested tables, simple pagination, bullets and numbering, Styles etc.

The fact is RTFDocument components arent written by swing team. If you check the source files you would see a lot of PENDING marks.
regards
843804
Thanks for the reply..
Can you please explain how you are doing table rendering by over-ridding the default implementation??
Thanks in advance..

subhrajyotim@yahoo.com
843804
1. Override EditorKit
public class MyRTFEditorKit extends StyledEditorKit {
...
public Document createDefaultDocument() {
return new MyRTFDocument();
}
public ViewFactory getViewFactory() {
return new RTFViewFactory();
}
...
}
The Document represents tree structure of the Elements.
You have to change this structure to reflect table.
previous structure
section
paragraph1
leaf1
leaf2
paragraph2
leaf3
after update
section
paragraph1
leaf1
leaf2
table
row1
cell1_1
paragraph1_1
paragraph1_2
cell1_2
row2
paragraph2
leaf3
then override ViewFactory.
Create views for reflect table element. See swing ParagraphView, BoxView, LabelView...

ViewFactory creates View for the Element.
Override it to obtain TableView for TableElement
RowView for RowElement etc.

EditorKit also contains reader and writer for document.
Change reader/writer.
843804
thanks a lot again.. but i am crudely new to Java.. and all this RTFEditorKit and StyledKit is just driving me nuts... can u please send me the code u are using .. i will try to atleast understand what you are trying to do ..
my email is subhrajyotim@yahoo.com

thanks a lot again in advance..
subhro.
843804
I have also been having a nightmare with this and my (1 man) project is running scarily behind schedule! If you could forward an additional copy of the source I would be very grateful. My email is nick.webb@jhb.co.uk
843804
Hi,

i've send you a letter with pieces of source code.

regards
Stas
843804
I'm running the same shit with bullets and Copy/Paste RTF from/to JTextPane in/from other application or JTextPane...

I'm really over my schedule so if someone can help it will be very very appreciated ...


Thanx a lot
843804
forget my email address : mcabaraux@cirb.irisnet.be

Thanx
843804
I am currently building an application which needs to display RTF document on JEditorPane and facing the same problem. Can you please also send me the source code?
my email: accod2001@yahoo.com.hk
843804
hello,

I've the same pbm of saving images/tables...
I would be glad if u post/send me some sample codes.
my mail id: anubecse@yahoo.com
TQ

anu
843804
---------------------------------------
---------------------------------------
843804
I'm also having same problem will really appreciate if i can get the sample code for tables and pictures...
my email id is shail_jayant@yahoo.com
thanx
843804
I am currently building an application which needs to display and save RTF document WITH TABLES on JEditorPane and facing the same problem.
Can you please also send me the source code ?
my email: lucdore@hotmail.com
TQ very much
843804
does your rtfeditor supports images?
843804
Stan can you please send me the code for the table support in RTF. I would be much obliged.

My e-id is amit17111978@yahoo.com

Regards,
Amit
843804
Like lots of other people I've got the same problem, and would appreciate it if you could send me the source examples you sent to others. I'm greg@arcadia-services.co.uk.

Theire is a bug reported in 1999 relating to tables and RTF which Sun decided not to fix through lack of interest. This forum would seem to prove them wrong.
843804
I would also appreciate if you could send me some sourcecode for handling tables in RTF. Or an URL where it is possible to download from.
Best Regards,
mimicry@spray.se
843804
We are also working with RTF and require extending RTFEditorKit. Could you please send us your current source code? We can also offer help extending the capabilities further. This would be a tremendous help to us.

Thank you,

Mark
mark@securedataprocessing.com
843804
Stan,

Can you please send me the RTF Writer code that allows download of images+text+tables type data on Office97+2000 compatiblity?
Please send it to pkk20012002@yahoo.com

Regards
843804
Hello, Stan
I've the same problem of saving images and tables. Can you please send me the sample codes. I would be much obliged.

My e-mail is charis@immsp.kiev.ua

Regards,
Charis
843804
hello,

I've the same pbm of saving images/tables...
I would be glad if u post/send me some sample codes.
my mail id: g.colli@gruppoinfo.it
TQ

GE
843804
There are so many people, all asking to be emailed source, including
myself. Is there anyone out there who could post some source here for
everyone to look at? It is obvious that meny people are interested in RTF.
843804
Hello, Stan

I've got the same problem of saving images and tables. Could you please send me the sample codes too. I would be much obliged.

My e-mail address is pshavel@tut.by

P.S. I agree with previest writer that it will be great to post your sample code here.

Thanks in advance.

Best Regards, Pavel.
843804
Hi

Could U plz send me the sample codes to... my email is:

e.e@sport.dk
843804
still waiting :(
843804
I am also trying to write a RTF editor using RTFDocument and RTFEditorKit. But I have problems to read and write tables, bullets, pictures, etc. If you could forward an additional copy of the source I would be very grateful. My email is luciana@dct.ufms.br

I would like also to know if the swing team is working in this pending thinks in RTFEditorKit.

Thanks in advance

Luciana

843804
As far as I'm aware all issues with RTF components in the bugs section have been closed and are not going to be fixed. Either it's time to get on the JCP or improve the components independantly ... hows about an open source project?
843804
It's really a shame to be the 100. person asking for the code ;), but I am searching for a solution of these problem since quite a time and it would be great if you could send me the essential parts of your code.
mail: waal@gmx.net

thx a lot
Patrick
843804
I sent a note to Sun about this, and the following was theire reply.


WOW, I must admit we are amazed that so many people are interested in
Swing's RTF support. Because of the immense popularity of html we have
been focusing our resources on Swing's html support, at the expense of
Swing's rtf support. Based on the feedback on the Swing forums we
will revisit this decision shortly and try and beef up Swing's RTF
support to a more modern version. As to your specific needs, we don't
have anything we can point you at now, but hopefully in the near
future we can craft something.

Thanks for your feedback,

-Scott Violet (scott.violet@sun.com)

843804
Sorry to bother you again with this problem, but I really need your work about advanced RTF support with java.text API. My e-mail is ahmeti@bornova.ege.edu.tr . Thanks in advance.
843804
Sorry to bother u too,And I Have The Same Problem Too, I really need your work about advanced RTF support picture API. My e-mail is pyzhang8@hotmail.com. Thanks in advance!

843804
Hi, I have the same old shit problem.. It would be really really great if you could send me the code also. Thanks a lot in advance.

My Id is shanksooo@hotmail.com

Your response would be greatly greatly appreciated.

Thanks
843804
Stan,

I would also appreciate if you could send me some sourcecode for handling tables in RTF. Best Regards,
khamoosh@mail.com
843804
Hello, Stan
I've the same problem of saving images and tables. Can you please send me the sample codes. I would be much obliged.

My e-mail is conta@alfacom.net

Regards,
Ihor


843804
Hello Stan,

I need to make a RTF Editor and I'm facing the same problems (images, tables, ...).
It could be very cool if you can send me your implementation of the RTF editor at franck.cohen@caramail.com

Regards.
843804
Hello Stan,

I am facing the same problems (images, tables, ...)with Rtf.
It could be very helpful if you can send me your implementation of the RTF editor at sindhu@viewset.com

Regards.
843804
MR. StanislavL
You seems to have a solution for Word2002 RTF documents and RTF with tables and pictures. Could you please tell me where I can get the RTFEditorKit you wrote.
I am also searching for a Java RTF printing solution. I found an example with the BoxView class but sometimes the line last character get clipped when the document is sent to the printer.
Thanks in advance.
843804
Stan -
I'm in the same boat as all these other people...
It looks like the solution that you wrote is in much demand!
.... Can you send me the code to you mentioned that supports RTF documents with tables and pictures... Thanks in advance
843804
THIS HAS TO STOP..... PPL LISTEN UP!! HE IS NOT SENDING ANYTHING TO ANYONE, SO STOP ASKING HIM FOR IT....



regards

aslan
843804
This is the first thread I've seen with this many requests for source code, I'm glad I'm not the only one asking. I am also working on a project that ABSOLUTELY MUST have table support in RTF documents. I would most appreciate any help with implementing the missing RTF tables/nested images support. At least this helped tremendously to get started! I hope the Swing team helps with this pretty critical issue.
843804
like so many others i am having trouble with the word2002 rtf format, its a real headache not made any easier by there being so little info available.

if anyone has any answers/work arounds or news when the swing team are going to update their rtfeditor please email me at ben@earko.com

thanks,

ben

843804
I am using the RTFEditorKit to translate RTF to HTML.
However, I found that since RTFEditorKit does not support tables. As a result, I stuck at there.
May you send me a piece of source code so that I can support RTF tables?
Thanks a lot.
my email address : noise_from_guitar@yahoo.com.hk
843804
Arg!! Got the same problem as the rest of you! it does seem to be such a big problem, I am surprised that Sun have not implimented this before. If everyone who needs this functionality from the rtfEditor submits on this forum then perhaps the powers that be will take notice and help us out!
I need this done in a week, so if I manage to get something working I will submit what I have done to you guys. So far I have ironed out the bug preventing Word2000, XP docs from working, but have only been working on this for two days with other stuff to do so more to come?? Lets hope so.
Regards
Mark
843804
I have the same problem too. We need to be able to view complex RTF in-line, as well as (hopefully) edit and save it. I can't believe no work has been done on this in the years Swing has been out! I've never seen an office store word processing documents in HTML - everyone uses RTF for cross-platform stuff. This is a must-have feature :-(

I'll echo the rest and say if anyone has source code further advanced than the default, i'd love to see it or talk about licensing. (alison@mirrabooka.com) Otherwise i guess i'll have to extend StyledEditorKit aswell. sigh
843804
Well i said i would keep you guys informed if i got anywhere. 5.30am - god i must be addicted! Well finaly got images read in from rtfReader/Parser from there just as a test i have outputted the images to file, been at it for hours but finaly it works. Word outputs a jpeg image in both compressed bmp format and in wmf, which makes it extreemly difficult to read in. I am only trying to read in rtf docs from Word for conversion to html in my project, i suspect that my implimentation will not be generic enough for most of you... But when i am done i am sure many of you will be able to use some of what i am doing as a starting point.
Perhaps Sun wants to employ me to do this for them???????
I graduate from uni in a few months, I need a job!!!
regards
Mark
843804
I suggest you to try with Majix, a java package that performs rtf 2 xml transformation.
It is available, with the source code written in Java under the Mozilla Public License 1.1.
the url is http://www.tetrasix.com/

ciao
Stefano
843804
Hello Stan,

I need to make a RTF Editor and I'm facing the same problems (images, tables, ...).
It could be very cool if you can send me your implementation of the RTF editor at dryckbosch@hotmail.com

Regards.
843804
Hi ,
I am workign on generatin RTF document through JAVA API , without using JTEXTEditor. What I am doing is , Reading the RTF structure (Table, Nested Tables and Text) all in Tree structure and write to RTF file.

For this purouse I am looking for some code or links on how to create RTF documents with Tables and Nested Tables.

I will really appreciate if you can Share this code/Knowledge with me.
Thanks in Advance
shriashish@hotmail.com
843804
Hi,

the same problem again !! anyone who solved the problem with tables and images pl. send the update/source code to keepupdating@lycos.com.

Thanks in advance.
843804
And yes, another one with problems with the RTFEditorKit. If anyone has a solution reading rtf files coming from office xp I would be very , very happy if you could send me a copy.

peterpbrouwer@cs.com
1 - 50 Next
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 16 2009
Added on Feb 13 2002
61 comments
805 views