001: /**
002: * Copyright (c) 2003-2005, www.pdfbox.org
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * 1. Redistributions of source code must retain the above copyright notice,
009: * this list of conditions and the following disclaimer.
010: * 2. Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: * 3. Neither the name of pdfbox; nor the names of its
014: * contributors may be used to endorse or promote products derived from this
015: * software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
018: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
019: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020: * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
021: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: *
028: * http://www.pdfbox.org
029: *
030: */package org.pdfbox.pdmodel.interactive.viewerpreferences;
031:
032: import org.pdfbox.cos.COSBase;
033: import org.pdfbox.cos.COSDictionary;
034:
035: import org.pdfbox.pdmodel.common.COSObjectable;
036:
037: /**
038: * This is the document viewing preferences.
039: *
040: * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
041: * @version $Revision: 1.3 $
042: */
043: public class PDViewerPreferences implements COSObjectable {
044: /**
045: * From PDF Reference: "Neither document outline nor thumbnail images visible".
046: */
047: public static final String NON_FULL_SCREEN_PAGE_MODE_USE_NONE = "UseNone";
048: /**
049: * From PDF Reference: "Document outline visible".
050: */
051: public static final String NON_FULL_SCREEN_PAGE_MODE_USE_OUTLINES = "UseOutlines";
052: /**
053: * From PDF Reference: "Thumbnail images visible".
054: */
055: public static final String NON_FULL_SCREEN_PAGE_MODE_USE_THUMBS = "UseThumbs";
056: /**
057: * From PDF Reference: "Optional content group panel visible".
058: */
059: public static final String NON_FULL_SCREEN_PAGE_MODE_USE_OPTIONAL_CONTENT = "UseOC";
060:
061: /**
062: * Reading direction.
063: */
064: public static final String READING_DIRECTION_L2R = "L2R";
065: /**
066: * Reading direction.
067: */
068: public static final String READING_DIRECTION_R2L = "R2L";
069:
070: /**
071: * Boundary constant.
072: */
073: public static final String BOUNDARY_MEDIA_BOX = "MediaBox";
074: /**
075: * Boundary constant.
076: */
077: public static final String BOUNDARY_CROP_BOX = "CropBox";
078: /**
079: * Boundary constant.
080: */
081: public static final String BOUNDARY_BLEED_BOX = "BleedBox";
082: /**
083: * Boundary constant.
084: */
085: public static final String BOUNDARY_TRIM_BOX = "TrimBox";
086: /**
087: * Boundary constant.
088: */
089: public static final String BOUNDARY_ART_BOX = "ArtBox";
090:
091: private COSDictionary prefs;
092:
093: /**
094: * Constructor that is used for a preexisting dictionary.
095: *
096: * @param dic The underlying dictionary.
097: */
098: public PDViewerPreferences(COSDictionary dic) {
099: prefs = dic;
100: }
101:
102: /**
103: * This will get the underlying dictionary that this object wraps.
104: *
105: * @return The underlying info dictionary.
106: */
107: public COSDictionary getDictionary() {
108: return prefs;
109: }
110:
111: /**
112: * Convert this standard java object to a COS object.
113: *
114: * @return The cos object that matches this Java object.
115: */
116: public COSBase getCOSObject() {
117: return prefs;
118: }
119:
120: /**
121: * Get the toolbar preference.
122: *
123: * @return the toolbar preference.
124: */
125: public boolean hideToolbar() {
126: return prefs.getBoolean("HideToolbar", false);
127: }
128:
129: /**
130: * Set the toolbar preference.
131: *
132: * @param value Set the toolbar preference.
133: */
134: public void setHideToolbar(boolean value) {
135: prefs.setBoolean("HideToolbar", value);
136: }
137:
138: /**
139: * Get the menubar preference.
140: *
141: * @return the menubar preference.
142: */
143: public boolean hideMenubar() {
144: return prefs.getBoolean("HideMenubar", false);
145: }
146:
147: /**
148: * Set the menubar preference.
149: *
150: * @param value Set the menubar preference.
151: */
152: public void setHideMenubar(boolean value) {
153: prefs.setBoolean("HideMenubar", value);
154: }
155:
156: /**
157: * Get the window UI preference.
158: *
159: * @return the window UI preference.
160: */
161: public boolean hideWindowUI() {
162: return prefs.getBoolean("HideWindowUI", false);
163: }
164:
165: /**
166: * Set the window UI preference.
167: *
168: * @param value Set the window UI preference.
169: */
170: public void setHideWindowUI(boolean value) {
171: prefs.setBoolean("HideWindowUI", value);
172: }
173:
174: /**
175: * Get the fit window preference.
176: *
177: * @return the fit window preference.
178: */
179: public boolean fitWindow() {
180: return prefs.getBoolean("FitWindow", false);
181: }
182:
183: /**
184: * Set the fit window preference.
185: *
186: * @param value Set the fit window preference.
187: */
188: public void setFitWindow(boolean value) {
189: prefs.setBoolean("FitWindow", value);
190: }
191:
192: /**
193: * Get the center window preference.
194: *
195: * @return the center window preference.
196: */
197: public boolean centerWindow() {
198: return prefs.getBoolean("CenterWindow", false);
199: }
200:
201: /**
202: * Set the center window preference.
203: *
204: * @param value Set the center window preference.
205: */
206: public void setCenterWindow(boolean value) {
207: prefs.setBoolean("CenterWindow", value);
208: }
209:
210: /**
211: * Get the display doc title preference.
212: *
213: * @return the display doc title preference.
214: */
215: public boolean displayDocTitle() {
216: return prefs.getBoolean("DisplayDocTitle", false);
217: }
218:
219: /**
220: * Set the display doc title preference.
221: *
222: * @param value Set the display doc title preference.
223: */
224: public void setDisplayDocTitle(boolean value) {
225: prefs.setBoolean("DisplayDocTitle", value);
226: }
227:
228: /**
229: * Get the non full screen page mode preference.
230: *
231: * @return the non full screen page mode preference.
232: */
233: public String getNonFullScreenPageMode() {
234: return prefs.getNameAsString("NonFullScreenPageMode",
235: NON_FULL_SCREEN_PAGE_MODE_USE_NONE);
236: }
237:
238: /**
239: * Set the non full screen page mode preference.
240: *
241: * @param value Set the non full screen page mode preference.
242: */
243: public void setNonFullScreenPageMode(String value) {
244: prefs.setName("NonFullScreenPageMode", value);
245: }
246:
247: /**
248: * Get the reading direction preference.
249: *
250: * @return the reading direction preference.
251: */
252: public String getReadingDirection() {
253: return prefs
254: .getNameAsString("Direction", READING_DIRECTION_L2R);
255: }
256:
257: /**
258: * Set the reading direction preference.
259: *
260: * @param value Set the reading direction preference.
261: */
262: public void setReadingDirection(String value) {
263: prefs.setName("Direction", value);
264: }
265:
266: /**
267: * Get the ViewArea preference. See BOUNDARY_XXX constants.
268: *
269: * @return the ViewArea preference.
270: */
271: public String getViewArea() {
272: return prefs.getNameAsString("ViewArea", BOUNDARY_CROP_BOX);
273: }
274:
275: /**
276: * Set the ViewArea preference. See BOUNDARY_XXX constants.
277: *
278: * @param value Set the ViewArea preference.
279: */
280: public void setViewArea(String value) {
281: prefs.setName("ViewArea", value);
282: }
283:
284: /**
285: * Get the ViewClip preference. See BOUNDARY_XXX constants.
286: *
287: * @return the ViewClip preference.
288: */
289: public String getViewClip() {
290: return prefs.getNameAsString("ViewClip", BOUNDARY_CROP_BOX);
291: }
292:
293: /**
294: * Set the ViewClip preference. See BOUNDARY_XXX constants.
295: *
296: * @param value Set the ViewClip preference.
297: */
298: public void setViewClip(String value) {
299: prefs.setName("ViewClip", value);
300: }
301:
302: /**
303: * Get the PrintArea preference. See BOUNDARY_XXX constants.
304: *
305: * @return the PrintArea preference.
306: */
307: public String getPrintArea() {
308: return prefs.getNameAsString("PrintArea", BOUNDARY_CROP_BOX);
309: }
310:
311: /**
312: * Set the PrintArea preference. See BOUNDARY_XXX constants.
313: *
314: * @param value Set the PrintArea preference.
315: */
316: public void setPrintArea(String value) {
317: prefs.setName("PrintArea", value);
318: }
319:
320: /**
321: * Get the PrintClip preference. See BOUNDARY_XXX constants.
322: *
323: * @return the PrintClip preference.
324: */
325: public String getPrintClip() {
326: return prefs.getNameAsString("PrintClip", BOUNDARY_CROP_BOX);
327: }
328:
329: /**
330: * Set the PrintClip preference. See BOUNDARY_XXX constants.
331: *
332: * @param value Set the PrintClip preference.
333: */
334: public void setPrintClip(String value) {
335: prefs.setName("PrintClip", value);
336: }
337: }
|