2 * Licensed to the Apache Software Foundation (ASF) under one or more
\r
3 * contributor license agreements. See the NOTICE file distributed with
\r
4 * this work for additional information regarding copyright ownership.
\r
5 * The ASF licenses this file to You under the Apache License, Version 2.0
\r
6 * (the "License"); you may not use this file except in compliance with
\r
7 * the License. You may obtain a copy of the License at
\r
9 * http://www.apache.org/licenses/LICENSE-2.0
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
17 package org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination;
\r
19 import org.apache.pdfbox.cos.COSArray;
\r
20 import org.apache.pdfbox.cos.COSBase;
\r
23 * This represents a destination to a page at a y location and the width is magnified
\r
24 * to just fit on the screen.
\r
26 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
\r
27 * @version $Revision: 1.2 $
\r
29 public class PDPageFitWidthDestination extends PDPageDestination
\r
33 * The type of this destination.
\r
35 protected static final String TYPE = "FitH";
\r
37 * The type of this destination.
\r
39 protected static final String TYPE_BOUNDED = "FitBH";
\r
42 * Default constructor.
\r
45 public PDPageFitWidthDestination()
\r
48 array.growToSize(3);
\r
49 array.setName( 1, TYPE );
\r
54 * Constructor from an existing destination array.
\r
56 * @param arr The destination array.
\r
58 public PDPageFitWidthDestination( COSArray arr )
\r
65 * Get the top y coordinate. A return value of -1 implies that the current y-coordinate
\r
68 * @return The top y coordinate.
\r
72 return array.getInt( 2 );
\r
76 * Set the top y-coordinate, a value of -1 implies that the current y-coordinate
\r
78 * @param y The top ycoordinate.
\r
80 public void setTop( int y )
\r
82 array.growToSize( 3 );
\r
85 array.set( 2, (COSBase)null );
\r
89 array.setInt( 2, y );
\r
94 * A flag indicating if this page destination should just fit bounding box of the PDF.
\r
96 * @return true If the destination should fit just the bounding box.
\r
98 public boolean fitBoundingBox()
\r
100 return TYPE_BOUNDED.equals( array.getName( 1 ) );
\r
104 * Set if this page destination should just fit the bounding box. The default is false.
\r
106 * @param fitBoundingBox A flag indicating if this should fit the bounding box.
\r
108 public void setFitBoundingBox( boolean fitBoundingBox )
\r
110 array.growToSize( 2 );
\r
111 if( fitBoundingBox )
\r
113 array.setName( 1, TYPE_BOUNDED );
\r
117 array.setName( 1, TYPE );
\r