diff options
Diffstat (limited to 'fop-core/src')
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java | 3 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/pdf/PDFLinkTestCase.java | 34 |
2 files changed, 23 insertions, 14 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java index 57f8a17a9..f0456a53f 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java @@ -589,6 +589,9 @@ public class PDFFactory { if (filename == null) { filename = uri.getSchemeSpecificPart(); } + if (scheme == null && filename.toLowerCase().endsWith(".pdf")) { + scheme = "file"; + } if (scheme == null) { return new PDFUri(uri.toASCIIString()); } else if (scheme.equalsIgnoreCase("embedded-file")) { diff --git a/fop-core/src/test/java/org/apache/fop/pdf/PDFLinkTestCase.java b/fop-core/src/test/java/org/apache/fop/pdf/PDFLinkTestCase.java index b4c6a5239..988a14668 100644 --- a/fop-core/src/test/java/org/apache/fop/pdf/PDFLinkTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/pdf/PDFLinkTestCase.java @@ -123,12 +123,12 @@ public class PDFLinkTestCase { {"/foo/bar 2.pdf", quote("<< /Type /Filespec /F (/foo/bar 2.pdf)")}, // PDF, Relative paths - {"foobar.pdf", quote("<< /URI (foobar.pdf)")}, //34 - {"foo bar.pdf", quote("<< /URI (foo%20bar.pdf)")}, - {"./foobar.pdf", quote("<< /URI (./foobar.pdf)")}, - {"./foo bar.pdf", quote("<< /URI (./foo%20bar.pdf)")}, - {"../foobar.pdf", quote("<< /URI (../foobar.pdf)")}, - {"../foo bar.pdf", quote("<< /URI (../foo%20bar.pdf)")}, + {"foobar.pdf", quote("<< /Type /Filespec /F (foobar.pdf)")}, //34 + {"foo bar.pdf", quote("<< /Type /Filespec /F (foo bar.pdf)")}, + {"./foobar.pdf", quote("<< /Type /Filespec /F (./foobar.pdf)")}, + {"./foo bar.pdf", quote("<< /Type /Filespec /F (./foo bar.pdf)")}, + {"../foobar.pdf", quote("<< /Type /Filespec /F (../foobar.pdf)")}, + {"../foo bar.pdf", quote("<< /Type /Filespec /F (../foo bar.pdf)")}, // PDF, Windows network paths {"\\\\foo\\bar.pdf", quote("<< /Type /Filespec /F (\\\\\\\\foo\\\\bar.pdf)")}, //40 @@ -165,12 +165,18 @@ public class PDFLinkTestCase { + quote("/D [ 2 /XYZ null null null ]")}, // PDF with fragments, Relative paths - {"foobar.pdf#dest=aa", quote("<< /URI (foobar.pdf#dest=aa)")}, //55 - {"foo bar.pdf#page=2", quote("<< /URI (foo%20bar.pdf#page=2)")}, - {"./foobar.pdf#dest=aa", quote("<< /URI (./foobar.pdf#dest=aa)")}, - {"./foo bar.pdf#page=2", quote("<< /URI (./foo%20bar.pdf#page=2)")}, - {"../foobar.pdf#dest=aa", quote("<< /URI (../foobar.pdf#dest=aa)")}, - {"../foo bar.pdf#page=2", quote("<< /URI (../foo%20bar.pdf#page=2)")}, + {"foobar.pdf#dest=aa", quote("<< /Type /Filespec /F (foobar.pdf)") + ".*" + quote("/S /GoToR") + ".*" + + quote("/D (aa)")}, //55 + {"foo bar.pdf#page=2", quote("<< /Type /Filespec /F (foo bar.pdf)") + ".*" + quote("/S /GoToR") + ".*" + + quote("/D [ 2 /XYZ null null null ]")}, + {"./foobar.pdf#dest=aa", quote("<< /Type /Filespec /F (./foobar.pdf)") + ".*" + quote("/S /GoToR") + + ".*" + quote("/D (aa)")}, + {"./foo bar.pdf#page=2", quote("<< /Type /Filespec /F (./foo bar.pdf)") + ".*" + quote("/S /GoToR") + ".*" + + quote("/D [ 2 /XYZ null null null ]")}, + {"../foobar.pdf#dest=aa", quote("<< /Type /Filespec /F (../foobar.pdf)") + ".*" + quote("/S /GoToR") + + ".*" + quote("/D (aa)")}, + {"../foo bar.pdf#page=2", quote("<< /Type /Filespec /F (../foo bar.pdf)") + ".*" + quote("/S /GoToR") + ".*" + + quote("/D [ 2 /XYZ null null null ]")}, // PDF with fragments, Windows network paths {"\\\\foo\\bar.pdf#dest=aa", quote("<< /Type /Filespec /F (\\\\\\\\foo\\\\bar.pdf)") + ".*" @@ -393,7 +399,7 @@ public class PDFLinkTestCase { {"file:examples.html", quote("<< /Type /Filespec /F (examples.html)")}, // parenthesis - {"simple_report_(version2.pdf", quote("<< /URI (simple_report_\\(version2.pdf)")} + {"simple_report_(version2.pdf", quote("<< /Type /Filespec /F (simple_report_\\(version2.pdf)")} }); } @@ -415,6 +421,6 @@ public class PDFLinkTestCase { Pattern r = Pattern.compile(expected); Matcher m = r.matcher(outString); - Assert.assertTrue(m.find()); + Assert.assertTrue(target + " " + outString, m.find()); } } |