Hi,

I am using itext for generation of an RTF document, the problem i am 
facing is with the use of "Anchors". Anchor doesn't give any error when 
used with html document but throws an exception when used with rtf. I have 
used the following code from the site of IText for generating 
crossreferences in html file and it works.

Anchor anchor1 = new Anchor("This is an internal link");
anchor1.setName("link1");
Anchor anchor2 = new Anchor("Go to the internal link");
anchor.setReference("#link1");

Following is an example which uses Anchor in the way which is similar to 
the way i am using in my code.


public static void main(String[] args) {
        Document document = new Document();
        try {
            RtfWriter2.getInstance(document, new 
FileOutputStream("LocalGoto.rtf"));
            document.open();
            Paragraph p1 = new Paragraph("We will do something special 
with this paragraph. If you click on ",
                 FontFactory.getFont(FontFactory.HELVETICA, 12));
            Anchor newAnchor = new Anchor("this word", 
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 
0, 255)));
            newAnchor.setReference("#test");
            p1.add(newAnchor);
            p1.add(" you will automatically jump to another location in 
this document.");
            Paragraph p3 = new Paragraph("This paragraph contains a ");
            Anchor refAnchor = new Anchor("local destination", 
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 
255, 0)));
            refAnchor.setName("test");
            p3.add(refAnchor);
            // we add the content
            document.newPage();
            document.add(p1);
            document.newPage();
            document.add(p3);
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
            System.err.println(ioe.getMessage());
        }
        document.close();
}


Can i get some help frm the people who have used cross references in rtf 
documents generated from itext.

With regards,
Pradeep Pandey




______________________________________________________________________
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to