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

I wouldn't say that my forming of the string was incorrect, because in the original form of the code, I could copy-and-paste the link's URL from the PDF into my browser and it would open the document, as expected.  In both forms, I use the same function to piece together the path, including the "file://" part.  The only difference between the method that works for me and the previous is that I do not specify a drive letter this time.  Instead, I specify the hostname that it should be found on since the document is located on a Windows 2000 network share, which all of our intranet users have mapped to S:\.

Dang Nguyen

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


setAnchor() accepts a URL or a String. Internally it's all converted to a
String. I suspect that you were not forming correctly the String. As the URL
enforces correctness your problem was solved.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Dang Nguyen [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, September 05, 2002 22:45
> To:   'Paulo Soares'; '[EMAIL PROTECTED]'
> Subject:      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