aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/pdf
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-01-21 10:33:10 +0000
committerJeremias Maerki <jeremias@apache.org>2008-01-21 10:33:10 +0000
commitec59ecf8a78788e07c53c0791cb54e6f5c0e7084 (patch)
treefd3499c7f44995a26b648d487f0b87c03ab25c29 /src/java/org/apache/fop/pdf
parent40f39c202ed281809d2c151144c5e36dd131fcb3 (diff)
downloadxmlgraphics-fop-ec59ecf8a78788e07c53c0791cb54e6f5c0e7084.tar.gz
xmlgraphics-fop-ec59ecf8a78788e07c53c0791cb54e6f5c0e7084.zip
A name object can be encoded as a stand-along PDF object with object number and all, so extend from PDFObject. Fixes a possible ClassCastException with the PDF-in-PDF extension.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@613831 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/pdf')
-rw-r--r--src/java/org/apache/fop/pdf/PDFName.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFName.java b/src/java/org/apache/fop/pdf/PDFName.java
index 8c626d53f..6ad6ff9eb 100644
--- a/src/java/org/apache/fop/pdf/PDFName.java
+++ b/src/java/org/apache/fop/pdf/PDFName.java
@@ -23,10 +23,12 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
+import org.apache.commons.io.output.CountingOutputStream;
+
/**
* Class representing a PDF name object.
*/
-public class PDFName implements PDFWritable {
+public class PDFName extends PDFObject {
private String name;
@@ -35,6 +37,7 @@ public class PDFName implements PDFWritable {
* @param name the name value
*/
public PDFName(String name) {
+ super();
this.name = escapeName(name);
}
@@ -75,6 +78,24 @@ public class PDFName implements PDFWritable {
}
/** {@inheritDoc} */
+ protected int output(OutputStream stream) throws IOException {
+ CountingOutputStream cout = new CountingOutputStream(stream);
+ Writer writer = PDFDocument.getWriterFor(cout);
+ if (hasObjectNumber()) {
+ writer.write(getObjectID());
+ }
+
+ outputInline(stream, writer);
+
+ if (hasObjectNumber()) {
+ writer.write("\nendobj\n");
+ }
+
+ writer.flush();
+ return cout.getCount();
+ }
+
+ /** {@inheritDoc} */
public void outputInline(OutputStream out, Writer writer) throws IOException {
writer.write(toString());
}