diff options
Diffstat (limited to 'src/java/org/apache/fop/pdf/PDFDestination.java')
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFDestination.java | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFDestination.java b/src/java/org/apache/fop/pdf/PDFDestination.java index c59b20cfc..eaf38449d 100644 --- a/src/java/org/apache/fop/pdf/PDFDestination.java +++ b/src/java/org/apache/fop/pdf/PDFDestination.java @@ -19,6 +19,12 @@ package org.apache.fop.pdf; +import java.io.IOException; +import java.io.OutputStream; +import java.io.Writer; + +import org.apache.commons.io.output.CountingOutputStream; + /** * class representing a named destination */ @@ -40,30 +46,24 @@ public class PDFDestination extends PDFObject { * @param goToRef Object reference to the GoTo Action */ public PDFDestination(String idRef, Object goToRef) { + super(); this.goToReference = goToRef; this.idRef = idRef; } - /** - * Creates the key/value pair for this destination entry for the name tree. - * @return the formatted key/value pair - */ - public String toKeyValuePair() { - StringBuffer sb = new StringBuffer(); - sb.append("(").append(getIDRef()).append(") "); - if (goToReference instanceof PDFWritable) { - sb.append(((PDFWritable)goToReference).toInlinePDFString()); - } else { - sb.append(goToReference); - } - return sb.toString(); - } - /** {@inheritDoc} */ - protected String toPDFString() { - return toKeyValuePair(); + protected int output(OutputStream stream) throws IOException { + CountingOutputStream cout = new CountingOutputStream(stream); + Writer writer = PDFDocument.getWriterFor(cout); + + formatObject(getIDRef(), cout, writer); + writer.write(' '); + formatObject(goToReference, cout, writer); + + writer.flush(); + return cout.getCount(); } - + /** * Sets the GoToReference in the associated DestinationData object. * @@ -124,9 +124,7 @@ public class PDFDestination extends PDFObject { return false; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public int hashCode() { return getIDRef().hashCode(); } |