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 ch...@apache.org on 2002/10/16 19:01:57 UTC

cvs commit: xml-fop/src/org/apache/fop/pdf PDFDocument.java PDFGoToRemote.java

chrisg      2002/10/16 10:01:56

  Modified:    .        status.xml
               docs/examples/fo link.fo
               src/org/apache/fop/pdf PDFDocument.java PDFGoToRemote.java
  Log:
  Addes Linking to a specific page and a named destinations of an
  external PDF file (see www.adobe.com/products/acrobat/pdfs/c01acrotip.pdf)
  Submitted by: Bernd Brandstetter <bb...@freenet.de>
  
  Revision  Changes    Path
  1.13      +6 -0      xml-fop/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/xml-fop/status.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- status.xml	13 Sep 2002 10:23:56 -0000	1.12
  +++ status.xml	16 Oct 2002 17:01:56 -0000	1.13
  @@ -123,6 +123,12 @@
   
     <changes>
      <release version="?" date="2002">
  +    <action dev="CG" type="add" context="code"
  +            due-to="Bernd Brandstetter" due-to-email="bbrand@freenet.de">
  +      Linking to a specific page and a named destinations of an
  +      external PDF file.
  +      (see www.adobe.com/products/acrobat/pdfs/c01acrotip.pdf)
  +    </action>
       <action context="code" dev="KLL" type="update">
         Started table layout managers.
       </action>
  
  
  
  1.9       +10 -0     xml-fop/docs/examples/fo/link.fo
  
  Index: link.fo
  ===================================================================
  RCS file: /home/cvs/xml-fop/docs/examples/fo/link.fo,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- link.fo	11 Dec 2001 12:08:28 -0000	1.8
  +++ link.fo	16 Oct 2002 17:01:56 -0000	1.9
  @@ -114,6 +114,16 @@
   				go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
   			</fo:block>
   
  +			<!-- Normal text -->
  +			<fo:block text-align="start"
  +								space-before.optimum="6pt"
  +								line-height="24pt"
  +								font-family="serif"
  +								padding-top="3pt"
  +								>
  +				9. Linking to a specific page of an external:
  +				<fo:basic-link external-destination="extensive.pdf#page=1">extensive.pdf, Page 2</fo:basic-link>.
  +			</fo:block>
   
   			<!-- Normal text -->
   <!--      <fo:block text-align="start"
  
  
  
  1.54      +18 -1     xml-fop/src/org/apache/fop/pdf/PDFDocument.java
  
  Index: PDFDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFDocument.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- PDFDocument.java	17 Sep 2002 09:20:57 -0000	1.53
  +++ PDFDocument.java	16 Oct 2002 17:01:56 -0000	1.54
  @@ -1233,6 +1233,7 @@
   
           PDFLink linkObject;
           PDFAction action;
  +        int index;
   
           PDFLink link = new PDFLink(++this.objectcount, rect);
           this.objects.add(link);
  @@ -1244,6 +1245,22 @@
                                                          destination);
                   this.objects.add(fileSpec);
                   action = new PDFGoToRemote(++this.objectcount, fileSpec);
  +                this.objects.add(action);
  +                link.setAction(action);
  +            } else if ((index = destination.indexOf(".pdf#page=")) > 0) {
  +                String file = destination.substring(0, index + 4);
  +                int page = Integer.parseInt(destination.substring(index + 10));
  +                PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount, file);
  +                this.objects.add(fileSpec);
  +                action = new PDFGoToRemote(++this.objectcount, fileSpec, page);
  +                this.objects.add(action);
  +                link.setAction(action);
  +            } else if ((index = destination.indexOf(".pdf#dest=")) > 0) {
  +                String file = destination.substring(0, index + 4);
  +                String dest = destination.substring(index + 10);
  +                PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount, file);
  +                this.objects.add(fileSpec);
  +                action = new PDFGoToRemote(++this.objectcount, fileSpec, dest);
                   this.objects.add(action);
                   link.setAction(action);
               } else {                               // URI
  
  
  
  1.4       +45 -4     xml-fop/src/org/apache/fop/pdf/PDFGoToRemote.java
  
  Index: PDFGoToRemote.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFGoToRemote.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PDFGoToRemote.java	30 Jul 2001 20:29:30 -0000	1.3
  +++ PDFGoToRemote.java	16 Oct 2002 17:01:56 -0000	1.4
  @@ -16,6 +16,8 @@
        * the file specification
        */
       protected PDFFileSpec pdfFileSpec;
  +    protected int pageReference = 0;
  +    protected String destination = null;
   
       /**
        * create an GoToR object.
  @@ -32,6 +34,38 @@
       }
   
       /**
  +     * create an GoToR object.
  +     *
  +     * @param number the object's number
  +     * @param fileSpec the fileSpec associated with the action
  +     * @param page a page reference within the remote document
  +     */
  +    public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec, int page) {
  +
  +        /* generic creation of object */
  +        super(number);
  +
  +        this.pdfFileSpec = pdfFileSpec;
  +        this.pageReference = page;
  +    }
  +
  +    /**
  +     * create an GoToR object.
  +     *
  +     * @param number the object's number
  +     * @param fileSpec the fileSpec associated with the action
  +     * @param dest a named destination within the remote document
  +     */
  +    public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec, String dest) {
  +
  +        /* generic creation of object */
  +        super(number);
  +
  +        this.pdfFileSpec = pdfFileSpec;
  +        this.destination = dest;
  +    }
  +
  +    /**
        * return the action string which will reference this object
        *
        * @return the action String
  @@ -48,9 +82,16 @@
       public byte[] toPDF() {
           String p = new String(this.number + " " + this.generation + " obj\n"
                                 + "<<\n/S /GoToR\n" + "/F "
  -                              + pdfFileSpec.referencePDF() + "\n"
  -                              + "/D [ 0 /XYZ null null null ]"
  -                              + " \n>>\nendobj\n");
  +                              + pdfFileSpec.referencePDF() + "\n");
  +
  +        if (destination != null) {
  +            p += "/D (" + this.destination + ")";
  +        } else {
  +            p += "/D [ " + this.pageReference + " /XYZ null null null ]";
  +        }
  +
  +        p += " \n>>\nendobj\n";
  +
           return p.getBytes();
       }
   
  
  
  

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