You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2008/01/21 11:33:11 UTC

svn commit: r613831 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFName.java

Author: jeremias
Date: Mon Jan 21 02:33:10 2008
New Revision: 613831

URL: http://svn.apache.org/viewvc?rev=613831&view=rev
Log:
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.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFName.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFName.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFName.java?rev=613831&r1=613830&r2=613831&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFName.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFName.java Mon Jan 21 02:33:10 2008
@@ -23,10 +23,12 @@
 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 @@
      * @param name the name value
      */
     public PDFName(String name) {
+        super();
         this.name = escapeName(name);
     }
 
@@ -74,6 +77,24 @@
         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());



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org