Title: RE: [iText-questions] Anchor.setReference not loading local file reference

I found the cause of my problem.  This is what worked for me:

            Chunk ck = new Chunk(cur_frd.filename(), FontFactory.getFont(FontFactory.HELVETICA, 10, Font.UNDERLINE, new java.awt.Color(0, 0, 255)));

           
            try {
                ck.setAnchor(new URL("file", "seint20.metapath.com",cur_frd.encode("frd")));
            }
            catch(MalformedURLException e) {
                e.printStackTrace();
            }


The difference here and what I had originally is the use of java.net.URL method.  In the original I called setAnchor and specified a string path (i.e., "file://seint20.metapath.com/path/to/the/file.doc").  This in turn is supposed to convert to a link to the file.  In the working example above, I create a URL object to the file, as a parameter to setAnchor. Perhaps there is a bug in the setAnchor method that accepts string object when it converts to the link?

Note: in my example above, cur_frd.encode("frd") is a method that returns a string consisting of a Windows path (e.g., "\path\to\file.doc").


Dang Nguyen

-----Original Message-----
From: Paulo Soares [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 04, 2002 11:15 AM
To: 'Dang Nguyen'; '[EMAIL PROTECTED]'
Subject: RE: [iText-questions] Anchor.setReference not loading local
file reference


This code works for me:

            Chunk ck = new Chunk(text, font);
            ck.setAnchor("file:///c:/consis_dump.txt");
            document.add(new Paragraph(ck));

with both Acrobat and Reader 5.05.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Dang Nguyen [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, September 04, 2002 19:03
> To:   '[EMAIL PROTECTED]'
> Subject:      [iText-questions] Anchor.setReference not loading local file
> reference
>
> In my iText-generated PDF document, I am attempting to create an Anchor
> which links to a file on the local network, which is accessible to all of
> our intranet users.  The URL is in the form "
> <file:///S:/path/to/the/file.doc>" but it does not work when users click
> on the link within the PDF document.  However, if this link is copied to
> the address bar of Internet Explorer, then the document is opened as
> expected.  What is my problem?
>
> Excerpt from my code:
>
>             Anchor frdDoc = new Anchor(cur_frd.filename(),
> FontFactory.getFont(FontFactory.HELVETICA, 10, Font.UNDERLINE, new
> java.awt.Color(0, 0, 255)));
>
>             frdDoc.setReference(" <file:///>".concat(cur_frd.filename()));
>
>             frdDoc.setName("frdDocLink");
>             paragraph.add(frdDoc);
>
> In the above snippet, cur_frd.filename() produces the drive letter, path
> and filename appropriately.
>
> Dang Nguyen
> [EMAIL PROTECTED]
> Marconi Wireless
> Direct Phone: 425-519-2043
> Fax: 425-519-7280
>

Reply via email to