Mark Hall <mhall <at> edu.uni-klu.ac.at> writes:

> 
> On Tuesday 25 October 2005 16:56, Stefano wrote:
> > Mark Hall <mhall <at> edu.uni-klu.ac.at> writes:
> > > On Tuesday 25 October 2005 15:47, Stefano wrote:
> > > > I saw that RtfWriter2 gives an error if u try to use an internal link:
> > >
> > > The RtfWriter2 does not support internal links.
> > >
> > > Greetings,
> > > Mark
> > <a name="internal link" href="#internal link"/>
> > and down
> > <a href="#internal link"/>
> >
> > it works, but the anchor is a like to its-self so u see the hand if u go
> > over, so i think that checking the url (before to write it in the method i
> > told to u) could be enough.
> I'm not quite sure how this would work, could you send me a code sample?
> 
> Greetings,
> Mark

THIS IS THE EXAMPLE IN I-TEXT'S DOCUMENTATION

public static void main(String[] args) {

                System.out.println("the Anchor object");

                // step 1: creation of a document-object
                Document document = new Document();
                try {
            // step 2:
            PdfWriter.getInstance(document, new FileOutputStream("AHref.pdf"));
            HtmlWriter.getInstance(document, new FileOutputStream
("AHref.html"));
            
            // step 3: we open the document
            document.open();
            
            // step 4:
            Paragraph paragraph = new Paragraph("Please visit my ");
            Anchor anchor1 = new Anchor("website (external reference)", 
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 
255)));
            anchor1.setReference("http://www.lowagie.com/iText/";);
            anchor1.setName("top");
            paragraph.add(anchor1);
            paragraph.add(new Chunk
(".\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"));
            document.add(paragraph);
            Anchor anchor2 = new Anchor("please jump to a local destination", 
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 
255)));
            anchor2.setReference("#top");
            document.add(anchor2);
                } catch (DocumentException de) {
                        System.err.println(de.getMessage());
                } catch (IOException ioe) {
                        System.err.println(ioe.getMessage());
                }

                // step 5: we close the document
                document.close();
        }


THIS IS MINE

public static void main(String[] args) {

                System.out.println("the Anchor object");

                // step 1: creation of a document-object
                Document document = new Document();
                try {
            // step 2:
            PdfWriter.getInstance(document, new FileOutputStream("AName.pdf"));
            HtmlWriter.getInstance(document, new FileOutputStream
("AName.html"));
            
            // step 3: we open the document
            document.open();
            
            // step 4:
            Paragraph paragraph = new Paragraph("");
            Anchor anchor1 = new Anchor("First line", FontFactory.getFont
(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255)));
            anchor1.setName("anchor");
            anchor1.setReference("#anchor");
            paragraph.add(anchor1);
            paragraph.add(new Chunk
(".\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"));
            document.add(paragraph);
            Anchor anchor2 = new Anchor("jump to first line", 
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, Color.BLUE));
            anchor2.setReference("#anchor");
            document.add(anchor2);
                } catch (DocumentException de) {
                        System.err.println(de.getMessage());
                } catch (IOException ioe) {
                        System.err.println(ioe.getMessage());
                }

                // step 5: we close the document
                document.close();
        }

If in my example your don't set the reference on anchor1, you get the error i 
wrote here in the first post.


Greetings
Stefano






-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to