aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/pdf/PDFFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/pdf/PDFFactory.java')
-rw-r--r--src/java/org/apache/fop/pdf/PDFFactory.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java
index fc6e6b9fa..a5beb4ec7 100644
--- a/src/java/org/apache/fop/pdf/PDFFactory.java
+++ b/src/java/org/apache/fop/pdf/PDFFactory.java
@@ -1011,6 +1011,10 @@ public class PDFFactory {
// HTTP URL?
if (targetLo.startsWith("http://")) {
return new PDFUri(target);
+ // Non PDF files. Try to /Launch them.
+ } else if (targetLo.startsWith("file://")) {
+ target = target.substring("file://".length());
+ return getLaunchAction(target);
// Bare PDF file name?
} else if (targetLo.endsWith(".pdf")) {
return getGoToPDFAction(target, null, -1, newWindow);
@@ -1105,6 +1109,37 @@ public class PDFFactory {
}
/**
+ * Creates and returns a launch pdf document action using
+ * <code>file</code> to create a file spcifiaciton for
+ * the document/file to be opened with an external application.
+ *
+ * @param file the pdf file name
+ * @return the pdf launch object
+ */
+ private PDFLaunch getLaunchAction(String file) {
+ getDocument().getProfile().verifyActionAllowed();
+
+ PDFFileSpec fileSpec = new PDFFileSpec(file);
+ PDFFileSpec oldSpec = getDocument().findFileSpec(fileSpec);
+
+ if (oldSpec == null) {
+ getDocument().registerObject(fileSpec);
+ } else {
+ fileSpec = oldSpec;
+ }
+ PDFLaunch launch = new PDFLaunch(fileSpec);
+ PDFLaunch oldLaunch = getDocument().findLaunch(launch);
+
+ if (oldLaunch == null) {
+ getDocument().registerObject(launch);
+ } else {
+ launch = oldLaunch;
+ }
+
+ return launch;
+ }
+
+ /**
* Make an outline object and add it to the given parent
*
* @param parent the parent PDFOutline object (may be null)