Read external RTF file...

Is it possible to read in the contents of an RTF file and
assign those contents to a variable like we can do with a standard
text file using ReadExtFile?
I'm working on a peice that will (hopefully) read in the
contents of an RTF file and adjust certain bits of the text
depending on other variables...

I agree and this is almost always the way I implement
external text that
needs almost any sort of formatting.
With comments and tags, I can easily read in an HTML doc,
find and make
changes to blocks of text, and re-write the document back out
as needed.
I use the IE ActiveX control to show the file, though Apurva
had a
well-regarded alternative solution at some point.
You could also 'walk the DOM' to effect changes to the HTML
page via IE
and CallSprite functions but that's a bit more complex.
Erik
Steve Howard **Community Expert** - eLearning + Mobile and
Devices wrote:
> If you can change the file format to HTML then I think
you can do what
> you want and run into many fewer issues. Plus HTM tags
are easier to
> read and write.
Erik Lord
http://www.capemedia.net
Adobe Community Expert - eLearning
http://www.adobe.com/communities/experts/
http://www.awaretips.net -
Authorware Tips!

Similar Messages

  • Why doesn't read the RTF file?

    Hello,
    Could anyone tell me what is the problem with the following code. It would
    read an 'rtf' file but it doesn't.
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.text.rtf.*;
    import java.io.*;
    import java.awt.event.*;
    public class Rtf extends JFrame {
    String filein = System.getProperty("user.dir")
    + System.getProperty("file.separator")
    + "BG.rtf";
    public Rtf() {
         RTFEditorKit rtfKit = new RTFEditorKit();
         DefaultStyledDocument doc = new DefaultStyledDocument();
         try {
              rtfKit.read( new FileInputStream( filein ), doc, 0 );
         } catch(Exception e) {
              System.out.println("Read error: " + e);
         System.out.println("doc.getLength: " + doc.getLength());
    public static void main(String[] args) {
    JFrame frame = new Rtf();
    During the execution the following lines are the result:
    Read error: java.lang.NullPointerException
    doc.getLength: 0
    Press any key to continue...
    Thank you in advance.

    If your rtf is made in word 2000 or newer version, rtf kit cannot read it and return null pointer statement

  • Reading an RTF file in Java

    Hi,
    Can someone tell me how can we read the data from an .rtf files like we do with text files in Java.
    I have seen solutions using Swing rtfeditor etc.. But I just need to read the data, I do not want to open rtf page.
    Any help would be appreciated.
    KK

    If you are not to "read" but to obtain bytes then you can modify this:
    //try{
      InputStream stream = new FileInputStream("cc.rtf");//file name is arbitrary
                                                                             //or BufferedInputStream can be used
       int n=0;
    while((n=stream.read())!=-1){
                System.out.print(Integer.toString(n));
                System.out.print(" ");
        System.out.println();
       if(stream!=null) stream.close();
    //   catch(IOException ioe){
    //       throw ioe;
    //  }

  • Reading external xml files from a jar

    Hi,
    I am trying to read an xml file from a jar (which is not present inside the jar ) .
    I am passing the file name as a string (like C:/folder/filename) to the SAXBuilder but it throwing
    unknown protocol: c error.
    i tried using an url , tried using a relative path but to no use.
    Need help in this regard urgently.
    TIA,
    Regards,
    Harsha

    Hi,
    Actually, my application needs to read two xml files , parse it, perform some operation and write
    the result to an output file.
    The names of the two xml files i mentioned, are specified in a properties file as absolute paths. (I even tried converting them to URIs)
    The xml files are in the same directory as the jar ( i dont know if it should matter as i am giving the absolute path).
    The main class reads the names of the files and passes the names as strings to the SAXBuilder.
    This is where i am getting an exception.
    Going by what you said, is it not possible for a java class to read a fie outside of the jar ? Is there no way to do this ? And right now i am not sure of how to go about this or if there's any work around . Any help would be appreciated.
    Kindly reply at the earliest
    TIA,
    Harsha

  • XI read external xml file (not in xi namespace format).

    Hi All,
    I got requirement to read xml file (generated by non-sap system) in this below format :
    <ns0:Envelope xmlns:ns0="http://xxxx_Payroll_Notification.Schemas.UPPYM_destination">
      <Header>
        <BusinessFunctionID>UPPYM</BusinessFunctionID>
        <MsgID>25e31c20-b44b-11dc-8a73-000ffe2704e0</MsgID>
      </Header>
      <Body>
        <BusinessData>
          <UPPYM>
            <Rec>
              <Data>1000000109.2007B10111080101010101         </Data>
            </Rec>
            <Rec>
              <Data>1000000209.2007B10111080101010101         </Data>
            </Rec>
          </UPPYM>
          <UPPYMD1>
            <Rec>
              <Data>10000001POT1         500050NO0001500           </Data>
            </Rec>
            <Rec>
              <Data>10000001POT2         700050NO0001502           </Data>
            </Rec>
          </UPPYMD1>
        </BusinessData>
      </Body>
    </ns0:Envelope>
    Since the namespace is not follow xi format, how can i read and parse all the information using
    file adapter ?
    Thank you and Best Regards
    Fernand

    You can parse all the information in the XML file/Flat file by using JAVA mapping by using DOM / SAX Parser.
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/rahul.nawale2/blog/2006/07/18/java-mapping-an-alternate-way-of-reading-a-csv-file
    /people/carlosivan.prietorubio/blog/2007/12/21/implementing-a-java-mapping-in-sap-pi
    /people/alessandro.guarneri/blog/2007/03/25/xi-java-mapping-helper-dom

  • Read external xml file

    hi,
    I want to load (some of the) content of an xml file into an
    array. (actionscript in FLEX)
    I found an example at the flex documentation (
    over
    here
    but when i try this examle:
    quote:
    <mx:Script>
    <![CDATA[
    var myXML:XML = new XML();
    var XML_URL:String = "http://www.example.com/Sample3.xml";
    var myXMLURL:URLRequest = new URLRequest(XML_URL);
    var myLoader:URLLoader = new URLLoader(myXMLURL);
    myLoader.addEventListener("complete", xmlLoaded);
    function xmlLoaded(evtObj:Event) {
    myXML = XML(myLoader.data);
    trace("Data loaded.");
    ]]>
    </mx:Script>
    i get two errors:
    - 1120: Acces of undifined property myLoader.
    - 1120: Acces of undifined property mxLoaded
    Can anyone tell me how i can solve this problem?

    You can't do all that stuff outside a function. The variables
    do not exist until they all have been created during the object
    instantiation.
    Declare the variables in the global scope, then do the value
    assignments in a function, say initApp(), that you call in the
    creationComplete event on the Application tag.
    Tracy

  • Find and replace in rtf file

    hello
    I would like to replace a bookmarks that are already created in a rtf template file
    I Know how to read the rtf file ,It is just that i can't figure out how to rplace a word inside this file
    here is my code
    File docFile = new File("C:\\test.rtf");
            FileReader reader = null;
            try {
                reader = new FileReader(docFile);
                 } catch (FileNotFoundException ex) {
                ex.printStackTrace();
            javax.swing.text.rtf.RTFEditorKit kit = new RTFEditorKit();
           // Document doc = jEditorPane1.getDocument();
            Document doc =  kit.createDefaultDocument();
            try {
                kit.read(reader, doc, 0);
                jEditorPane1.setText(doc.getText(0,doc.getLength()));
            } catch (BadLocationException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            }thank you in advance

    thank y every one for being fast but I have found how to do it
    File docFile = new File("C:\\test.rtf");
            File outFile = new File("C:\\test2.rtf");
            FileWriter writer=null;
            FileReader reader = null;
            try {
                reader = new FileReader(docFile);
                 } catch (FileNotFoundException ex) {
                ex.printStackTrace();
            javax.swing.text.rtf.RTFEditorKit kit = new RTFEditorKit();
           // Document doc = jEditorPane1.getDocument();
            Document doc =  kit.createDefaultDocument();
            try {
                kit.read(reader, doc, 0);
               String text=doc.getText(0,doc.getLength());
               text=text.replaceAll("&nom&","my name");
                //jEditorPane1.setText(doc.getText(0,doc.getLength()));
               jEditorPane1.setText(text);
               writer=new FileWriter(outFile);
               writer.write(text);
               writer.close();
               reader.close();
            } catch (BadLocationException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            }

  • How to save contents of two different rich edit box into single rtf file in windows 8.1 app

    Developer, I have requirement to save registration data into rtf file.. These can only be done by if I put rich edit box to fill the data.. Now if I am going to write the code for saving the data of different rich edit box into one particular file, it
    only saves the data of last rich edit box.. So plzz suggest that how can I save the contents of different rich edit box together into one rtf file.

    Ok Nishant, just did some quick research, since rtf file is unlike txt file, we cannot simply directly write some content to the rtf.
    You can try to find some third party code that can help you insert text into rtf file or you would like to load the content from rtf out to the richeditbox and merge them to one richeditbox and then save back to the file.
    You could like to see how to read/save rtf file sample from:
    RichEditBox class
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Dropbox will not allow me  to view my rtf files on my ipad

    since IOS8 update i can not read my rtf files unless i  open them in another  app. I have too many  important files I have to spend  too much time opening them now Dropbox has quickly  become a useless app . Apple  does not  recognize this  issue ?  or  what....  am I  to do. Help if you can please! thanks, Jody A. i will wait  a while. Ps I  tried uninstalling and  reinstalling  the app but to no avail did   the  problem cease....

    I had rtf file problems as well--on GoodReader and Dropbox--as soon as I got my iPhone 6 Plus with iOS 8 on it, but updating to iOS 8.1 today appears to have resolved those. It was listed as a known problem that they had fixed in the betas of iOS 8.1 and happily it seems to have come through, at least for those apps. (I didn't even have update to the most recent versions of GoodReader or Dropbox to get the functionality of rtf files back in those apps.) Try updating to iOS 8.1 and see if things resolve.

  • Read external XML

    I'm using adobe designer 7 . I want to read external XML file with javascript
    there is a method XMLData.parse(String param1, Boolean param2) but it takes as parameter only string.
    How can I get external XML file convert it to string and pass it to XMLData.parse(param1, param2)?

    You are right there are more than one line in it. But the line which I posted above is the line which parse the string cXMLDoc
    Consider the XML document as first introduced in the example following the XMLData.applyXPath
    method.
    var x = XMLData.parse( cXMLDoc, false );
    var y = x.family.name; // An XFAObject
    console.println(y.value); // Output to console is "Robat"
    Get information about dad.
    y = x.family.dad.id; // An XFAObject
    console.println(y.value); // Output to console is "m2"
    y = x.family.dad.name.value; // y = "Bob"
    x.family.dad.name.value = "Robert"; // Change name to "Robert"
    y = x.family.dad.name.value; // y = "Robert"
    y = x.family.dad.personal.income.value; // y = "75000"
    x.family.dad.personal.income.value = "80000"; // Give dad a raise

  • My Macbook Pro can't detect or read my CDFS file system external HDD

    My Macbook Pro can't detect or read my CDFS file system external HDD

    Open Disk Utility and see if the USB drives show in there. If they don't then it is a USB port or bus problem. If they do show in disk utility are they formatted in either Mac extended or a Windows format?

  • How To Read RTF file in JAVA?  Using  iText?

    How To Read RTF file in JAVA?  Using  iText?.....
    import java.io.*;
    import com.lowagie.text.*;
    import com.lowagie.text.rtf.*;
    public class RTF3 {
    public static void main(String[] args) {
    // System.out.println("This example generate a RTF file name Sample.rtf");
    // Create Document object
    Document myDoc = new Document();
    try {
    // Create writer to listen document object
    // and directs RTF Stream to the file Sample.rtf
    RtfWriter2.getInstance(myDoc, new FileOutputStream("Sample.rtf"));
    // open the document object
    myDoc.open();
    // Create a paragraph
         Paragraph p = new Paragraph();
         p.add("Helloworld in Rtf file..amazing isn't");
         // Add the paragraph to document object
    myDoc.add(p);
    catch(Exception e) {
    System.out.println(e);
    //close the document
    myDoc.close();
    Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.Rectangle.width()F
         at com.lowagie.text.rtf.document.RtfPageSetting.rectEquals(RtfPageSetting.java:433)
         at com.lowagie.text.rtf.document.RtfPageSetting.guessFormat(RtfPageSetting.java:362)
         at com.lowagie.text.rtf.document.RtfPageSetting.setPageSize(RtfPageSetting.java:341)
         at com.lowagie.text.rtf.RtfWriter2.setPageSize(RtfWriter2.java:248)
         at com.lowagie.text.Document.open(Unknown Source)
         at view.RTF3.main(RTF3.java:23)
    CAN you HELP me?

    import com.lowagie.text.Document;
    import com.lowagie.text.rtf.parser.RtfParser;
    import java.io.FileInputStream;
    String inputFile = "sample.rtf";
    Document document = new Document();
    document.open();
    RtfParser parser = new RtfParser(null);
    parser.convertRtfDocument(new FileInputStream(inputFile), document);

  • Can I change the file path that itunes reads my music files from? 65000 files trying to be transferrd from external to internal HD. I dont want itunes to manage my collection, just read it. thanks

    Can I change the file path that itunes reads my music files from?
    I have about 65000 music files that i have transferrd from my external to a new laptop internal HD.
    I have organised the folders myself as I use a PC and do not want itunes to organise the folders because when I'm searching through music on windows it is sorted out by artists/albums with 'the...(eg  The Beatles)' under 'T' instead of 'B'.
    Long story short.... Is there any way that I can keep my itunes library as it is on the external HD and copy it to the new laptops C drive, keep all the info (playlists etc) and still have the same folder structure as on the external HD?
    Or, is there any way of making windows sort things in alphabetical order like it is in itunes (eliminating the 'the' issue)?

    The files that weren't inside the media folder on the original machine need to be copied over to exactly the same paths as they had on the source machine. See this thread for an ongoing discussion of a similar problem. See also this post on migrating the iTunes library.
    tt2

  • Read from external source file in weblogic

    Hi,
    I am using Weblogic Server 10.3 in my project.
    In one of my modules , i have a requirement where I have to read the contents of a file from an external location.[ex: D:\Test\Sample.xml ].
    How to i configure this path in weblogic , so that I can read the content in my java source file.
    Please advice.
    Regards,
    Praveen

    only part i replied on was the part of how to read a file
    but i think in your case you could do the next
    use the sync file adapter to read in the file during your process
    based on this content you set a variable "myOutputDirectory"
    then create a file adapter (write) which will store the file on file system
    http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_file.htm#CIACICFD
    4.3.2.2.5 Specifying a Dynamic Outbound File Name
    and use that (jca.file.Directory) property to store the file either on the archive location or the delete location

  • Reading an external text file in WAR file

    Greetings,
    I have a question. I have an web application that writes a text message and 0's and 1's based on checkboxes. Then I have a JSP that reads this text file and prints the message and enables/disables links based on the 1's and 0's. I don't have any problems with this when testing from localhost, but when I deploy to a server the application isn't reading the file. The text file and WAR file are in the same folder, same directory. I've tried using both relative and absolute paths to read the file, but to no avail. Is there an easy way to read an external file from a WAR file or is there an easier solution. Thanks
    Nick

    You should not try to force your text file to live in the same directory as the WAR file. Instead, you should remove that kind of dependency and instead be using something like System.getProperty("java.io.tmpdir") to use the temporary directory to create and delete these files.
    Edit: I also bet you don't even need to create & read a file here. You could probably store the information in one of the contexts of the web app, such as in a Session. I'll assume you know what that means.
    By creating a file, you are also running the risk of multiple threads (simultaneous users) vying for the same file name, thus walking on each other's data.
    Message was edited by:
    warnerja

Maybe you are looking for