1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination; 18 19 import org.apache.pdfbox.cos.COSArray; 20 21 /** 22 * This represents a destination to a page and the page contents will be magnified to just 23 * fit on the screen. 24 * 25 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a> 26 * @version $Revision: 1.2 $ 27 */ 28 public class PDPageFitDestination extends PDPageDestination 29 { 30 /** 31 * The type of this destination. 32 */ 33 protected static final String TYPE = "Fit"; 34 /** 35 * The type of this destination. 36 */ 37 protected static final String TYPE_BOUNDED = "FitB"; 38 39 /** 40 * Default constructor. 41 * 42 */ 43 public PDPageFitDestination() 44 { 45 super(); 46 array.growToSize(2); 47 array.setName( 1, TYPE ); 48 49 } 50 51 /** 52 * Constructor from an existing destination array. 53 * 54 * @param arr The destination array. 55 */ 56 public PDPageFitDestination( COSArray arr ) 57 { 58 super( arr ); 59 } 60 61 /** 62 * A flag indicating if this page destination should just fit bounding box of the PDF. 63 * 64 * @return true If the destination should fit just the bounding box. 65 */ 66 public boolean fitBoundingBox() 67 { 68 return TYPE_BOUNDED.equals( array.getName( 1 ) ); 69 } 70 71 /** 72 * Set if this page destination should just fit the bounding box. The default is false. 73 * 74 * @param fitBoundingBox A flag indicating if this should fit the bounding box. 75 */ 76 public void setFitBoundingBox( boolean fitBoundingBox ) 77 { 78 array.growToSize( 2 ); 79 if( fitBoundingBox ) 80 { 81 array.setName( 1, TYPE_BOUNDED ); 82 } 83 else 84 { 85 array.setName( 1, TYPE ); 86 } 87 } 88 }