Article View: borland.public.jbuilder.java.swing
Article #9751Problem generating RTF by Program
From: Volker Raum
Date: Mon, 17 Jan 2000 00:00
Date: Mon, 17 Jan 2000 00:00
64 lines
2547 bytes
2547 bytes
Hi, everybody
i am having big problems if i try to generate formatted !!!!! RTF-Files
by program.
I implemented a test-routine to demonstrate the problem:
HTMLEditorKit myHTML = new HTMLEditorKit() ;
RTFEditorKit myRTF = new RTFEditorKit() ;
DefaultStyledDocument mySDoc = new DefaultStyledDocument();
// Document myDoc = myRTF.createDefaultDocument () ;
// mySDoc = (DefaultStyledDocument) myDoc;
SimpleAttributeSet TabAttSet = new SimpleAttributeSet() ;
TabStop first = new TabStop( 50, TabStop.ALIGN_LEFT,
TabStop.LEAD_NONE ) ;
TabStop second = new TabStop( 100, TabStop.ALIGN_LEFT,
TabStop.LEAD_NONE ) ;
TabStop third = new TabStop( 250, TabStop.ALIGN_LEFT,
TabStop.LEAD_NONE ) ;
TabSet tabs = new TabSet( new TabStop[] { first, second,third} ) ;
SimpleAttributeSet Tabs = new SimpleAttributeSet() ;
StyleConstants.setTabSet (Tabs, tabs);
int offset ;
try
{
mySDoc.insertString(mySDoc.getLength (),
"\t1.Tab\t2.Tab\t3.Tab", null );
mySDoc.setParagraphAttributes (0,mySDoc.getLength
(),Tabs,false);
}
catch (Exception Ex)
{
Ex.printStackTrace ();
}
jTextPane1.setDocument (mySDoc);
try
{
FileOutputStream ofs = new FileOutputStream(
"k:\\rtfoutput.rtf" ) ;
myRTF.write( ofs, mySDoc, 0, mySDoc.getLength ()) ;
ofs.close();
ofs = new FileOutputStream( "k:\\htmloutput.htm" ) ;
myHTML.write( ofs, mySDoc, 0, mySDoc.getLength ()) ;
ofs.close();
}
catch ( Exception Ex )
{
Ex.printStackTrace ();
}
If i display the processed Document mySDoc in a JTextPane everything is
fine. The Tabs are set correctly,
but the written file rtfoutput.rtf does not contain any TABSTOP
definitions at all. What do i have to do to get
the correct RTF paragraph settings for Tabstops.
thanks in advance
Volker
Volker.Raum@datech.heitec.de
Technical Details
Message-ID:
<3883022A.446CD65F@datech.heitec.de>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,4668413df96c3542,start X-Google-Attributes: gid111d45,public From: Volker Raum <Volker.Raum@datech.heitec.de> Subject: Problem generating RTF by Program Date: 2000/01/17 Message-ID: <3883022A.446CD65F@datech.heitec.de> X-Deja-AN: 573706365 Content-Transfer-Encoding: 7bit Organization: Another Netscape Collabra Server User Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing