]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
A name object can be encoded as a stand-along PDF object with object number and all...
authorJeremias Maerki <jeremias@apache.org>
Mon, 21 Jan 2008 10:33:10 +0000 (10:33 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 21 Jan 2008 10:33:10 +0000 (10:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@613831 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/pdf/PDFName.java

index 8c626d53f0e705c182f0584bca8612cf7f6ef224..6ad6ff9eb5347ed2657d4d6769b4bf7f956a5d76 100644 (file)
@@ -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);
     }
 
@@ -74,6 +77,24 @@ public class PDFName implements PDFWritable {
         return this.name;
     }
 
+    /** {@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());