You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Derek Poon <dp...@ocf.berkeley.edu> on 2004/12/09 15:57:58 UTC

Implementing default zoom

Hello,

I'd like to set the initial zoom of my FOP-generated PDF document to
"Fit Visible".  According to the PDF Specification, an /OpenAction entry
in the catalog can be used to accomplish this.
( http://partners.adobe.com/public/developer/en/pdf/PDFReference13.pdf ,
Sec 7.2.1.)  Below, I have included the patch with the minimal kludge
that I devised to implement Fit Visible.

Of course, I'm hoping to implement something more flexible and elegant
-- perhaps an extension element to allow the initial view to be
specified in the FO document.  Does anyone have any suggestions for what
the syntax of such an element should be?  Maybe something like

  <fo:root xmlns:fo="..." xmlns:fox="...">
    <fox:initial-view page="..." zoom="fit-visible"/>
    <fo:layout-master-set>
      ...
    </fo:layout-master-set>
    ...
  </fo:root>

Derek


--- fop-0.20.5/src/org/apache/fop/pdf/PDFRoot.java.defaultzoom	2003-07-15 02:03:24.000000000 +0000
+++ fop-0.20.5/src/org/apache/fop/pdf/PDFRoot.java	2004-11-17 01:14:27.000000000 +0000
@@ -145,6 +145,13 @@
                                           + " obj\n<< /Type /Catalog\n/Pages "
                                           + this.rootPages.referencePDF()
                                           + "\n");
+        // Set the initial view to the first page, with Fit Visible as the
+        // default magnification
+        if (this.rootPages.kids.size() > 0) {
+            p.append("/OpenAction [");
+            p.append(this.rootPages.kids.get(0));
+            p.append(" /FitBH null]\n");
+        }
         if (_outline != null) {
             p.append(" /Outlines " + _outline.referencePDF() + "\n");
             p.append(" /PageMode /UseOutlines\n");