Hi All!

I just downloaded the iText Api today and am trying to Acheive a couple of
things :

1) To Append a String at the end of a file 
2) To read-edit the custom properties/bookmarks of the Document(*.rtf) 

For 1)  I tried two approaches , using the document.bottom() function and
the importRtfDocument() (separately,commented). In both cases , the content
of the original document is lost :-

public static void main(String[] args) throws IOException {
      //  System.out.println("Hello World! example for the RTF format");
        try {
            // Step 1: Create a new Document
            Document document = new Document();

            
            // Step 2: Create a new instance of the RtfWriter2 with the
document
            //         and target output stream.
          RtfWriter2 rtfw =  RtfWriter2.getInstance(document, new
FileOutputStream("C:/HelloWorld.rtf"));

           document.open();

          rtfw.importRtfDocument(new FileInputStream("C:/Insert.rtf"));
          

            // Step 4: Add content to the document.
         //   document.add(new Paragraph("Hello World!"));

            document.bottom();
            String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
            String TimeNow=null;
            Calendar cal = Calendar.getInstance();
            SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
            TimeNow=sdf.format(cal.getTime());

         //   document.add(new Paragraph("\r\n This document has been
Electronically Signed by Erica  Green, MD on " +TimeNow +"." ));

         
            // Step 5: Close the document. It will be written to the target
output stream.
            document.close();
        } catch (FileNotFoundException fnfe) {
            // It might not be possible to create the target file.
            fnfe.printStackTrace();
        } catch (DocumentException de) {
            // DocumentExceptions arise if you add content to the document
before opening or
            // after closing the document.
            de.printStackTrace();
        }
    }
}

How do I append text to a file without losing the original contents?

For problem 2) Which iText Api do i use to read/write the custom properties
of an RTF file. I am particualrly interested in modifying the bookmarks.

Any help is greatly appreciated.


-- 
View this message in context: 
http://www.nabble.com/How-to-append-Text-at-the-end-of-an-RTF-file--tp21068912p21068912.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to