]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added internal-link functionality
authorJordan Naftolin <jordan@apache.org>
Wed, 21 Jun 2000 01:47:18 +0000 (01:47 +0000)
committerJordan Naftolin <jordan@apache.org>
Wed, 21 Jun 2000 01:47:18 +0000 (01:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193421 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/render/pdf/PDFRenderer.java

index 02d5fa522929fd59fa2921d1d0893384ea8cfef6..986ebcd7cc3d3dbdbc425b55c8334e258f4b9c33 100644 (file)
@@ -55,6 +55,7 @@ package org.apache.fop.render.pdf;
 import org.apache.fop.render.Renderer;
 import org.apache.fop.image.ImageArea;
 import org.apache.fop.image.FopImage;
+import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.properties.*;
 import org.apache.fop.layout.*;
 import org.apache.fop.datatypes.*;
@@ -139,18 +140,27 @@ public class PDFRenderer implements Renderer {
         *
         * @param areaTree the laid-out area tree
         * @param writer the PrintWriter to write the PDF with
-        */
-       public void render(AreaTree areaTree, PrintWriter writer)
-       throws IOException {
-       System.err.println("rendering areas to PDF");
-       this.pdfResources = this.pdfDoc.getResources();
-       Enumeration e = areaTree.getPages().elements();
-       while (e.hasMoreElements()) {
-               this.renderPage((Page) e.nextElement());
-       }
-       System.err.println("writing out PDF");
-       this.pdfDoc.output(writer);
-       }
+        */     
+        public void render(AreaTree areaTree, PrintWriter writer)
+        throws IOException, FOPException {      
+            System.err.println("rendering areas to PDF");
+            IDReferences idReferences=areaTree.getIDReferences();           
+            this.pdfResources = this.pdfDoc.getResources();            
+            this.pdfDoc.setIDReferences(idReferences);
+            Enumeration e = areaTree.getPages().elements(); 
+            while ( e.hasMoreElements() ) {
+                this.renderPage((Page) e.nextElement());                
+            }
+    
+            if ( !idReferences.isEveryIdValid() ) {
+                throw new FOPException("The id \""+idReferences.getNextInvalidId()+"\" was referenced but does not exist\n");            
+            }
+    
+            System.err.println("writing out PDF");
+            this.pdfDoc.output(writer);
+        }
+
+
 
        /**
         * add a line to the current stream
@@ -510,7 +520,7 @@ public class PDFRenderer implements Renderer {
 
        currentPage = this.pdfDoc.makePage(this.pdfResources, currentStream,
                                 page.getWidth()/1000,
-                                page.getHeight()/1000);
+                                page.getHeight()/1000, page);
 
        if (page.hasLinks()) {
                currentAnnotList = this.pdfDoc.makeAnnotList();
@@ -522,11 +532,12 @@ public class PDFRenderer implements Renderer {
 
                linkSet.align();
                String dest = linkSet.getDest();
+                int linkType = linkSet.getLinkType();
                Enumeration f = linkSet.getRects().elements();
                while (f.hasMoreElements()) {
                        LinkedRectangle lrect = (LinkedRectangle) f.nextElement();
                        currentAnnotList.addLink(
-                               this.pdfDoc.makeLink(lrect.getRectangle(), dest));
+                               this.pdfDoc.makeLink(lrect.getRectangle(), dest, linkType));
                }
                }
        } else {