aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/pdf/AbstractPDFStream.java
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2015-02-24 11:23:44 +0000
committerSimon Steiner <ssteiner@apache.org>2015-02-24 11:23:44 +0000
commit77e0508bb36a6c5e547857f2bea17e1def2a2abc (patch)
tree92f26caed0d59eba746b306b69a84e6895e610d8 /src/java/org/apache/fop/pdf/AbstractPDFStream.java
parentc85d08c4b9adbf8135e18ad9c3f94e3469e4e12e (diff)
downloadxmlgraphics-fop-77e0508bb36a6c5e547857f2bea17e1def2a2abc.tar.gz
xmlgraphics-fop-77e0508bb36a6c5e547857f2bea17e1def2a2abc.zip
FOP-2445: Merge PDF Linearization branch
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1661887 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/pdf/AbstractPDFStream.java')
-rw-r--r--src/java/org/apache/fop/pdf/AbstractPDFStream.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/java/org/apache/fop/pdf/AbstractPDFStream.java b/src/java/org/apache/fop/pdf/AbstractPDFStream.java
index 331d4f7a5..e550f7e24 100644
--- a/src/java/org/apache/fop/pdf/AbstractPDFStream.java
+++ b/src/java/org/apache/fop/pdf/AbstractPDFStream.java
@@ -21,6 +21,7 @@ package org.apache.fop.pdf;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Set;
import org.apache.commons.io.output.CountingOutputStream;
@@ -36,7 +37,9 @@ public abstract class AbstractPDFStream extends PDFObject {
/** The filters that should be applied */
private PDFFilterList filters;
- private final boolean encodeOnTheFly;
+ private boolean encodeOnTheFly;
+
+ private PDFNumber refLength = new PDFNumber();
protected AbstractPDFStream() {
this(true);
@@ -220,11 +223,11 @@ public abstract class AbstractPDFStream extends PDFObject {
StringBuilder textBuffer = new StringBuilder(64);
StreamCache encodedStream = null;
- PDFNumber refLength = null;
final Object lengthEntry;
if (encodeOnTheFly) {
- refLength = new PDFNumber();
- getDocumentSafely().registerObject(refLength);
+ if (!refLength.hasObjectNumber()) {
+ registerChildren();
+ }
lengthEntry = refLength;
} else {
encodedStream = encodeStream();
@@ -281,4 +284,18 @@ public abstract class AbstractPDFStream extends PDFObject {
protected boolean multipleFiltersAllowed() {
return true;
}
+
+ @Override
+ public void getChildren(Set<PDFObject> children) {
+ dictionary.getChildren(children);
+ if (encodeOnTheFly) {
+ children.add(refLength);
+ }
+ }
+
+ public void registerChildren() {
+ if (encodeOnTheFly) {
+ getDocument().registerObject(refLength);
+ }
+ }
}