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