When the links to the external file are created with current PdfAction
constructor, Acrobat Reader has problems launching the external file if the
path is relative to the PDF file. But the following PdfAction extension seems
to work more constently:
public class LaunchPdfAction extends PdfAction {
/** Creates a new instance of LaunchPdfAction */
public LaunchPdfAction(String path, PdfWriter writer) throws
java.io.IOException {
put(PdfName.S, PdfName.LAUNCH);
PdfFileSpecification pfs=PdfFileSpecification.fileExtern(writer, path);
put(PdfName.F, pfs.getReference());
}
}
--- On Thu, 8/28/08, Jianhua Jin <[EMAIL PROTECTED]> wrote:
From: Jianhua Jin <[EMAIL PROTECTED]>
Subject: Re: [iText-questions] Launch/Open external non-PDF file
To: [email protected]
Date: Thursday, August 28, 2008, 5:38 PM
In PDF file there are at least two ways to specify a link to external files:
The first one is this (as it turns out, Acrobat Reader has problem launching
the document)
127 0 obj<</Border[0 0 0]/Rect[669.16 447.6 729.14 457.6]/Subtype/Link/C[0 0
1]/A<</S/Launch/Win<</D(.\\docs)/F(dm.xpt)/O(open)>>>>>>
endobj
This can be done with PdfAction action=new PdfAction("dm.xpt", null, "open",
".\\docs");
The other one is the following - do we have a PdfAction that create the content
like this? If no, what do I need to do to create a PdfAction myself (I am in a
hurry to get the job done, no time to go throught the iText source code). It
seems that Acrobat Reader works well with this style.
1246 0 obj
<<
/S /Launch
/F 1247 0 R
>>
endobj
1247 0 obj
<<
/Type /Filespec
/F (ae.xpt)
>>
--- On Wed, 8/27/08, Jianhua Jin <[EMAIL PROTECTED]> wrote:
From: Jianhua Jin <[EMAIL PROTECTED]>
Subject: Re: [iText-questions] Launch/Open external non-PDF file
To: [email protected]
Date: Wednesday, August 27, 2008, 12:33 PM
OK, more information I found out - when clicking the link, sometimes Acrobat
launches the external application with the full absolute path to the external
file (i.e., it combines the information from the D word and F word, and
translates the '.' to the parent Dir of the PDF file, this is Acrobat 7.0.0),
but sometimes it only provides the path that is defined in the F word (this is
in 7.0.8)
I am not sure if this is related to the viewer preferences, or the Acrobat
configuration.
Can anyone shed light how to deal with this issue?
--- On Wed, 8/27/08, Jianhua Jin <[EMAIL PROTECTED]> wrote:
From: Jianhua Jin <[EMAIL PROTECTED]>
Subject: [iText-questions] Launch/Open external non-PDF file
To: [email protected]
Date: Wednesday, August 27, 2008, 11:27 AM
I need to link a PDF file with some external non PDF files. The external files
are saved in a location that is fixed relative to the PDF file - if the PDF
file is saved in c:\pdf, then the external files must be saved under
c:\pdf\docs. I need to use relative path to reference these files.
Here is the code I used to set up the link:
chunk=new Chunk(text, link_font);
PdfAction action=new PdfAction("dm.xpt", null, "open", ".\\docs");
chunk.setAction(action);
and here is the link in the PDF file
127 0 obj<</Border[0 0 0]/Rect[669.16 447.6 729.14
457.6]/Subtype/Link/C[0 0
1]/A<</S/Launch/Win<</D(.\\docs)/F(dm.xpt)/O(open)>>>>>>
endobj
But the link does not work SOMETIMES. When click on the link, sometimes it can
find the file, but sometimes it cant't (I verified that the file is there). I
use Acrobat 7.0 to view the PDF files. It works if viewed in Windows XP
(personal computer), but doesnt work in Windows 2000 (corporate network).
I am using iText version: 2.1.3, JRE 5.0
Any thought would be appreciated.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book:
http://www.1t3xt.com/docs/book.php-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book:
http://www.1t3xt.com/docs/book.php-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php