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;
}
+ /** [EMAIL PROTECTED] */
+ 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();
+ }
+
/** [EMAIL PROTECTED] */
public void outputInline(OutputStream out, Writer writer) throws
IOException {
writer.write(toString());
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]