Hi for internal links Word obviously generates a bookmark and then the internal link references the bookmark.
In iText links are defined as described in the tutoral http://itextdocs.lowagie.com/tutorial/objects/anchors/index.html Currently from the behaviour specified in the tutorial the RtfWriter2 only implements the external Anchors. You will have to extend the RtfAnchor class to also handle internal links. Greetings, Mark On Tuesday 17 January 2006 20:48, Divya Nagireddy wrote: > Hi Mark, > > This is how I'm creating the RTF document > > Document document = new Document(); > RtfWriter2 writer2 = RtfWriter2.getInstance(document, new > FileOutputStream(rtfFile)); > document.open(); > - > - > //add various Elements to the document > document.add(); > - > - > //create a hyperlink for one of the elements, when you click on this > element it goes to a different element in the same doc. > Anchor anchor = new Anchor("Element2"); > //this works if the below string is replaced with an external URL > anchor.setReference("_Recording_List"); > - > - > document.close(); > > > Rtf format generated by Word: > Hyperlink - > {\field{\*\fldinst HYPERLINK \\l "_Recording_List" }{\fldrslt > \pard\f0\fs20\cf0 Element2}} > > When you click on the Element2 it goes to the destination, for which the > format is as follows - > {\*\bkmkstart _Recording_List}{\*\bkmkend _Recording_List}Element5 > > > I didn't quite understand if RtfAnchor is being used in hyperlink > generation. I also tried RtfWriter which seems to be using Anchor. > > Thanks again for your help > Divya > > >From: Mark Hall <[EMAIL PROTECTED]> > >To: [email protected] > >CC: "Divya Nagireddy" <[EMAIL PROTECTED]> > >Subject: Re: [iText-questions] Hyperlink to a different location in the > > RTF doc > >Date: Fri, 6 Jan 2006 15:02:39 +0100 > > > >On Thursday 05 January 2006 22:15, Divya Nagireddy wrote: > > > Any hint on how to implement it? > > > >You need to read the RTF 1.6 specification > >(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnrtfspe > >c/html/rtfspec.asp) and also look at what Word generates when you have a > > document with internal links. This is a bit of a pain since Word doesn't > > always fully follow the specification. > > > >Then you have to modify the code that writes Anchor objects to also handle > >internal links (com.lowagie.text.rtf.field.RtfAnchor). > > > >Depending on how internal anchors are implemented in RTF (I haven't looked > >into it) you might have to parse the generated RTF document a second time > >to > >correct the references. But since I haven't looked into this, I can't say > >whether this is really necessary. > > > >I think these three steps should cover most of the process. If you've got > >further questions on the internal workings of the RTF generation, just > > ask. > > > >Greetings, > >Mark > >-- > >You have the power to influence all with whom you come in contact. > > > >My GPG public key is available at: > >http://www.edu.uni-klu.ac.at/~mhall/data/security/MarkHall.asc > > > > > ><< attach3 >> -- You are fighting for survival in your own sweet and gentle way. My GPG public key is available at: http://www.edu.uni-klu.ac.at/~mhall/data/security/MarkHall.asc
pgp4QlIggxh4A.pgp
Description: PGP signature
