NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

How to write to a file including character attributes

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
madroadbiker



Joined: 29 Apr 2012
Posts: 6

PostPosted: Sat May 12, 2012 12:39 pm    Post subject: How to write to a file including character attributes Reply with quote

This was originally posted to the wrong forum so I am posting it where I was told to instead.

I have an application which has two text panes. The user can enter text into the text panes with attributes like underline, bold, italics, subscript, and superscript and it all looks fine in the text panes. I enable the user to save the contents of the text pane into a file in either plain text, pdf, or xml. I am using iText for the pdf output and java.beans XMLEncoder for xml output. Neither format saves the character attributes. They both save in plain text.

Here is how I am trying to save in xml format (contentWindow is a textPane):

Code:

XMLEncoder encoder =
    new XMLEncoder(
        new BufferedOutputStream(
            new FileOutputStream(fileName)));
     encoder.writeObject(contentWindow.getText());
     encoder.close();

What am I doing wrong?
Back to top
madroadbiker



Joined: 29 Apr 2012
Posts: 6

PostPosted: Mon May 21, 2012 3:48 pm    Post subject: Reply with quote

Can someone please help with this? Either with the xml output or pdf. I can not figure out how to output what is displayed in my text panes including the character attributes to either an xml or pdf file. A detailed example would be nice. Thanks.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo