Index: src/java/org/apache/fop/pdf/PDFFactory.java
===================================================================
--- src/java/org/apache/fop/pdf/PDFFactory.java	(revision 1056512)
+++ src/java/org/apache/fop/pdf/PDFFactory.java	(working copy)
@@ -1082,16 +1082,22 @@
         } else if (targetLo.endsWith(".pdf")) {
             // Bare PDF file name?
             return getGoToPDFAction(target, null, -1, newWindow);
-        } else if ((index = targetLo.indexOf(".pdf#page=")) > 0) { // CSOK: InnerAssignment
-            // PDF file + page?
+        } else if ((index = targetLo.indexOf(".pdf#")) > 0) { // CSOK: InnerAssignment
             String filename = target.substring(0, index + 4);
-            int page = Integer.parseInt(target.substring(index + 10));
-            return getGoToPDFAction(filename, null, page, newWindow);
-        } else if ((index = targetLo.indexOf(".pdf#dest=")) > 0) { // CSOK: InnerAssignment
-            // PDF file + destination?
-            String filename = target.substring(0, index + 4);
-            String dest = target.substring(index + 10);
-            return getGoToPDFAction(filename, dest, -1, newWindow);
+            String tmp = targetLo.substring(index + 5, index + 10);
+            int page = -1;
+            String dest = null;
+            if ("page=".equals(tmp)) {
+                // PDF file + page?
+                page = Integer.parseInt(target.substring(index + 10));
+            } else {
+                // PDF file + named destination?
+                dest = target.substring(index + ("dest=".equals(tmp) ? 10 : 5));
+            }
+            return getGoToPDFAction(filename, dest, page, newWindow);
+        } else if (target.startsWith("#")) {
+            //actually an _internal_ named destination
+            return getPDFGoTo(target.substring(1), true, null);
         } else {
             // None of the above? Default to URI:
             return new PDFUri(target);
@@ -1159,25 +1165,32 @@
      * @return the GoTo's object reference
      */
     public String getGoToReference(String pdfPageRef, float yoffset) {
-        return getPDFGoTo(pdfPageRef, new Point2D.Float(0.0f, yoffset)).referencePDF();
+        return getPDFGoTo(pdfPageRef, false, new Point2D.Float(0.0f, yoffset)).referencePDF();
     }
 
     /**
      * Finds and returns a PDFGoTo to the given page and position.
      * Creates the PDFGoTo if not found.
      *
-     * @param pdfPageRef the PDF page reference
-     * @param position the (X,Y) position in points
+     * @param pdfDestinationRef    the PDF destination reference
+     * @param isNamedDestination   indicates whether the destination reference is a
+     *                             named destination (if {@code true}, the position
+     *                             parameter is ignored)
+     * @param position             the (X,Y) position in points
      *
      * @return the new or existing PDFGoTo object
      */
-    public PDFGoTo getPDFGoTo(String pdfPageRef, Point2D position) {
+    public PDFGoTo getPDFGoTo(String pdfDestinationRef, boolean isNamedDestination, Point2D position) {
         getDocument().getProfile().verifyActionAllowed();
-        PDFGoTo gt = new PDFGoTo(pdfPageRef, position);
+        PDFGoTo gt;
+        if (isNamedDestination) {
+            gt = new PDFGoTo(pdfDestinationRef, isNamedDestination);
+        } else {
+            gt = new PDFGoTo(pdfDestinationRef, position);
+        }
         PDFGoTo oldgt = getDocument().findGoTo(gt);
         if (oldgt == null) {
-            getDocument().assignObjectNumber(gt);
-            getDocument().addTrailerObject(gt);
+            getDocument().registerObject(gt);
         } else {
             gt = oldgt;
         }
Index: src/java/org/apache/fop/pdf/PDFGoTo.java
===================================================================
--- src/java/org/apache/fop/pdf/PDFGoTo.java	(revision 1056512)
+++ src/java/org/apache/fop/pdf/PDFGoTo.java	(working copy)
@@ -32,9 +32,10 @@
      * the pageReference
      */
     private String pageReference;
-    private String destination = null;
+    private String positionDestination = null;
     private float xPosition = 0;
     private float yPosition = 0;
+    private final String namedDestination;
 
     /**
      * create a /GoTo object.
@@ -44,9 +45,28 @@
     public PDFGoTo(String pageReference) {
         super();
         setPageReference(pageReference);
+        this.namedDestination = null;
     }
 
     /**
+     * create a /GoTo object
+     *
+     * @param destinationRef        the destination reference represented by this object
+     * @param isNamedDestination    indicates whether the destinationRef is a named destination
+     *                              if {@code false}, the destinationRef is interpreted to
+     *                              be a page reference
+     */
+    public PDFGoTo(String destinationRef, boolean isNamedDestination) {
+        super();
+        if (!isNamedDestination) {
+            setPageReference(destinationRef);
+            this.namedDestination = null;
+        } else {
+            this.namedDestination = destinationRef;
+        }
+    }
+
+    /**
      * create a /GoTo object.
      *
      * @param pageReference the PDF reference to the target page
@@ -96,12 +116,13 @@
     }
 
     /**
-     * Set the destination string for this Goto.
+     * Set the positionDestination string for this Goto.
+     * (Only has effect if it does not point to a named positionDestination)
      *
-     * @param dest the PDF destination string
+     * @param dest the PDF positionDestination string
      */
     public void setDestination(String dest) {
-        destination = dest;
+        this.positionDestination = dest;
     }
 
     /**
@@ -113,16 +134,16 @@
         return referencePDF();
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public String toPDFString() {
-        String dest;
-        if (destination == null) {
-            dest = "/D [" + this.pageReference + " /XYZ " + xPosition
-                          + " " + yPosition + " null]\n";
+        String dest = "/D ";
+        if (this.namedDestination != null) {
+            dest += "(" + this.namedDestination + ")";
+        } else if (this.positionDestination != null) {
+            dest += "[" + this.pageReference + " " + this.positionDestination + "]";
         } else {
-            dest = "/D [" + this.pageReference + " " + destination + "]\n";
+            dest += "[" + this.pageReference + " /XYZ "
+                    + this.xPosition + " " + this.yPosition + " null]";
         }
         return getObjectID()
                     + "<< /Type /Action\n/S /GoTo\n" + dest
@@ -151,28 +172,21 @@
 
         PDFGoTo gt = (PDFGoTo)obj;
 
-        if (gt.pageReference == null) {
-            if (pageReference != null) {
-                return false;
+        if (this.pageReference == null) {
+            return (gt.pageReference == null
+                && gt.namedDestination != null
+                && gt.namedDestination.equals(this.namedDestination));
+        } else if (this.pageReference.equals(gt.pageReference)) {
+            if (this.positionDestination == null) {
+                return (gt.positionDestination == null
+                        && gt.xPosition == this.xPosition
+                        && gt.yPosition == this.yPosition);
+            } else {
+                return (this.positionDestination.equals(gt.positionDestination));
             }
-        } else {
-            if (!gt.pageReference.equals(pageReference)) {
-                return false;
-            }
         }
 
-        if (destination == null) {
-            if (!(gt.destination == null && gt.xPosition == xPosition
-                && gt.yPosition == yPosition)) {
-                return false;
-            }
-        } else {
-            if (!destination.equals(gt.destination)) {
-                return false;
-            }
-        }
-
-        return true;
+        return false;
     }
 }
 
