aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2010-08-16 09:39:34 +0000
committerJeremias Maerki <jeremias@apache.org>2010-08-16 09:39:34 +0000
commitcb9936b4c92ee6f4dede21dbd2fe6d3395b9c31c (patch)
tree4e022c5663696161f5d32fc858c633d4390ae891 /src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
parentefea814f6945dd13595a4d6767ebf6b57f68df1b (diff)
downloadxmlgraphics-fop-cb9936b4c92ee6f4dede21dbd2fe6d3395b9c31c.tar.gz
xmlgraphics-fop-cb9936b4c92ee6f4dede21dbd2fe6d3395b9c31c.zip
Improvements/Bugfixes for PDF attachments (embedded files):
- Acrobat doesn't like indirect objects for the /Length entry of embedded files (make on-the-fly generation more easily configurable). - Added the /Size entry for embedded files to keep Acrobat happy. - Moved the embedded files' Names tree to the end of the PDF to be on the safe side. - Made hyperlinks to embedded files work by using a JavaScript Action (thanks to Matthias Reischenbacher for that idea). - Added sorting to the names tree node because Acrobat relies on it. - Added some filename manipulation code to work around possible encoding problems with special characters in the filenames. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@985843 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java')
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
index f6123fb33..b7ad9cf71 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
@@ -61,6 +61,7 @@ import org.apache.fop.pdf.PDFNumsArray;
import org.apache.fop.pdf.PDFOutputIntent;
import org.apache.fop.pdf.PDFPageLabels;
import org.apache.fop.pdf.PDFReference;
+import org.apache.fop.pdf.PDFText;
import org.apache.fop.pdf.PDFXMode;
import org.apache.fop.render.pdf.extensions.PDFEmbeddedFileExtensionAttachment;
import org.apache.fop.util.ColorProfileUtil;
@@ -453,7 +454,8 @@ class PDFRenderingUtil implements PDFConfigurationConstants {
}
PDFDictionary dict = new PDFDictionary();
dict.put("F", file);
- PDFFileSpec fileSpec = new PDFFileSpec(embeddedFile.getFilename());
+ String filename = PDFText.toPDFString(embeddedFile.getFilename(), '_');
+ PDFFileSpec fileSpec = new PDFFileSpec(filename);
fileSpec.setEmbeddedFile(dict);
if (embeddedFile.getDesc() != null) {
fileSpec.setDescription(embeddedFile.getDesc());
@@ -464,7 +466,8 @@ class PDFRenderingUtil implements PDFConfigurationConstants {
PDFNameTreeNode embeddedFiles = names.getEmbeddedFiles();
if (embeddedFiles == null) {
embeddedFiles = new PDFNameTreeNode();
- //this.pdfDoc.registerObject(embeddedFiles);
+ this.pdfDoc.assignObjectNumber(embeddedFiles);
+ this.pdfDoc.addTrailerObject(embeddedFiles);
names.setEmbeddedFiles(embeddedFiles);
}
@@ -474,7 +477,8 @@ class PDFRenderingUtil implements PDFConfigurationConstants {
nameArray = new PDFArray();
embeddedFiles.setNames(nameArray);
}
- nameArray.add(embeddedFile.getFilename());
+ String name = PDFText.toPDFString(filename);
+ nameArray.add(name);
nameArray.add(new PDFReference(fileSpec));
}