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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.apache.pdfbox.pdmodel.interactive.viewerpreferences;
19 import org.apache.pdfbox.cos.COSBase;
20 import org.apache.pdfbox.cos.COSDictionary;
22 import org.apache.pdfbox.pdmodel.common.COSObjectable;
25 * This is the document viewing preferences.
27 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
28 * @version $Revision: 1.3 $
30 public class PDViewerPreferences implements COSObjectable
33 * From PDF Reference: "Neither document outline nor thumbnail images visible".
35 public static final String NON_FULL_SCREEN_PAGE_MODE_USE_NONE = "UseNone";
37 * From PDF Reference: "Document outline visible".
39 public static final String NON_FULL_SCREEN_PAGE_MODE_USE_OUTLINES = "UseOutlines";
41 * From PDF Reference: "Thumbnail images visible".
43 public static final String NON_FULL_SCREEN_PAGE_MODE_USE_THUMBS = "UseThumbs";
45 * From PDF Reference: "Optional content group panel visible".
47 public static final String NON_FULL_SCREEN_PAGE_MODE_USE_OPTIONAL_CONTENT = "UseOC";
52 public static final String READING_DIRECTION_L2R = "L2R";
56 public static final String READING_DIRECTION_R2L = "R2L";
61 public static final String BOUNDARY_MEDIA_BOX = "MediaBox";
65 public static final String BOUNDARY_CROP_BOX = "CropBox";
69 public static final String BOUNDARY_BLEED_BOX = "BleedBox";
73 public static final String BOUNDARY_TRIM_BOX = "TrimBox";
77 public static final String BOUNDARY_ART_BOX = "ArtBox";
80 private COSDictionary prefs;
83 * Constructor that is used for a preexisting dictionary.
85 * @param dic The underlying dictionary.
87 public PDViewerPreferences( COSDictionary dic )
93 * This will get the underlying dictionary that this object wraps.
95 * @return The underlying info dictionary.
97 public COSDictionary getDictionary()
103 * Convert this standard java object to a COS object.
105 * @return The cos object that matches this Java object.
107 public COSBase getCOSObject()
113 * Get the toolbar preference.
115 * @return the toolbar preference.
117 public boolean hideToolbar()
119 return prefs.getBoolean( "HideToolbar", false );
123 * Set the toolbar preference.
125 * @param value Set the toolbar preference.
127 public void setHideToolbar( boolean value )
129 prefs.setBoolean( "HideToolbar", value );
133 * Get the menubar preference.
135 * @return the menubar preference.
137 public boolean hideMenubar()
139 return prefs.getBoolean( "HideMenubar", false );
143 * Set the menubar preference.
145 * @param value Set the menubar preference.
147 public void setHideMenubar( boolean value )
149 prefs.setBoolean( "HideMenubar", value );
153 * Get the window UI preference.
155 * @return the window UI preference.
157 public boolean hideWindowUI()
159 return prefs.getBoolean( "HideWindowUI", false );
163 * Set the window UI preference.
165 * @param value Set the window UI preference.
167 public void setHideWindowUI( boolean value )
169 prefs.setBoolean( "HideWindowUI", value );
173 * Get the fit window preference.
175 * @return the fit window preference.
177 public boolean fitWindow()
179 return prefs.getBoolean( "FitWindow", false );
183 * Set the fit window preference.
185 * @param value Set the fit window preference.
187 public void setFitWindow( boolean value )
189 prefs.setBoolean( "FitWindow", value );
193 * Get the center window preference.
195 * @return the center window preference.
197 public boolean centerWindow()
199 return prefs.getBoolean( "CenterWindow", false );
203 * Set the center window preference.
205 * @param value Set the center window preference.
207 public void setCenterWindow( boolean value )
209 prefs.setBoolean( "CenterWindow", value );
213 * Get the display doc title preference.
215 * @return the display doc title preference.
217 public boolean displayDocTitle()
219 return prefs.getBoolean( "DisplayDocTitle", false );
223 * Set the display doc title preference.
225 * @param value Set the display doc title preference.
227 public void setDisplayDocTitle( boolean value )
229 prefs.setBoolean( "DisplayDocTitle", value );
233 * Get the non full screen page mode preference.
235 * @return the non full screen page mode preference.
237 public String getNonFullScreenPageMode()
239 return prefs.getNameAsString( "NonFullScreenPageMode", NON_FULL_SCREEN_PAGE_MODE_USE_NONE);
243 * Set the non full screen page mode preference.
245 * @param value Set the non full screen page mode preference.
247 public void setNonFullScreenPageMode( String value )
249 prefs.setName( "NonFullScreenPageMode", value );
253 * Get the reading direction preference.
255 * @return the reading direction preference.
257 public String getReadingDirection()
259 return prefs.getNameAsString( "Direction", READING_DIRECTION_L2R);
263 * Set the reading direction preference.
265 * @param value Set the reading direction preference.
267 public void setReadingDirection( String value )
269 prefs.setName( "Direction", value );
273 * Get the ViewArea preference. See BOUNDARY_XXX constants.
275 * @return the ViewArea preference.
277 public String getViewArea()
279 return prefs.getNameAsString( "ViewArea", BOUNDARY_CROP_BOX);
283 * Set the ViewArea preference. See BOUNDARY_XXX constants.
285 * @param value Set the ViewArea preference.
287 public void setViewArea( String value )
289 prefs.setName( "ViewArea", value );
293 * Get the ViewClip preference. See BOUNDARY_XXX constants.
295 * @return the ViewClip preference.
297 public String getViewClip()
299 return prefs.getNameAsString( "ViewClip", BOUNDARY_CROP_BOX);
303 * Set the ViewClip preference. See BOUNDARY_XXX constants.
305 * @param value Set the ViewClip preference.
307 public void setViewClip( String value )
309 prefs.setName( "ViewClip", value );
313 * Get the PrintArea preference. See BOUNDARY_XXX constants.
315 * @return the PrintArea preference.
317 public String getPrintArea()
319 return prefs.getNameAsString( "PrintArea", BOUNDARY_CROP_BOX);
323 * Set the PrintArea preference. See BOUNDARY_XXX constants.
325 * @param value Set the PrintArea preference.
327 public void setPrintArea( String value )
329 prefs.setName( "PrintArea", value );
333 * Get the PrintClip preference. See BOUNDARY_XXX constants.
335 * @return the PrintClip preference.
337 public String getPrintClip()
339 return prefs.getNameAsString( "PrintClip", BOUNDARY_CROP_BOX);
343 * Set the PrintClip preference. See BOUNDARY_XXX constants.
345 * @param value Set the PrintClip preference.
347 public void setPrintClip( String value )
349 prefs.setName( "PrintClip", value );