File: PdfViewerPreferences.cs

package info (click to toggle)
pdfmod 0.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 5,196 kB
  • ctags: 9,346
  • sloc: cs: 50,590; xml: 1,177; sh: 709; makefile: 640
file content (321 lines) | stat: -rw-r--r-- 13,491 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#region PDFsharp - A .NET library for processing PDF
//
// Authors:
//   Stefan Lange (mailto:Stefan.Lange@pdfsharp.com)
//
// Copyright (c) 2005-2008 empira Software GmbH, Cologne (Germany)
//
// http://www.pdfsharp.com
// http://sourceforge.net/projects/pdfsharp
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
#endregion

using System;
using System.Collections;
using System.Globalization;
using System.Text;
using System.IO;
using PdfSharp.Internal;
using PdfSharp;

namespace PdfSharp.Pdf
{
  /// <summary>
  /// Represents the PDF document viewer preferences dictionary.
  /// </summary>
  public sealed class PdfViewerPreferences : PdfDictionary
  {
    internal PdfViewerPreferences(PdfDocument document)
      : base(document)
    { }

    /// <summary>
    /// Initializes a new instance of the <see cref="PdfViewerPreferences"/> class.
    /// </summary>
    PdfViewerPreferences(PdfDictionary dict)
      : base(dict)
    { }

    /// <summary>
    /// Gets or sets a value indicating whether to hide the viewer applications tool
    ///  bars when the document is active.
    /// </summary>
    public bool HideToolbar
    {
      get { return Elements.GetBoolean(Keys.HideToolbar); }
      set { Elements.SetBoolean(Keys.HideToolbar, value); }
    }

    /// <summary>
    /// Gets or sets a value indicating whether to hide the viewer applications
    /// menu bar when the document is active.
    /// </summary>
    public bool HideMenubar
    {
      get { return Elements.GetBoolean(Keys.HideMenubar); }
      set { Elements.SetBoolean(Keys.HideMenubar, value); }
    }

    /// <summary>
    /// Gets or sets a value indicating whether to hide user interface elements in
    /// the documents window (such as scroll bars and navigation controls),
    /// leaving only the documents contents displayed.
    /// </summary>
    public bool HideWindowUI
    {
      get { return Elements.GetBoolean(Keys.HideWindowUI); }
      set { Elements.SetBoolean(Keys.HideWindowUI, value); }
    }

    /// <summary>
    /// Gets or sets a value indicating whether to resize the documents window to
    /// fit the size of the first displayed page.
    /// </summary>
    public bool FitWindow
    {
      get { return Elements.GetBoolean(Keys.FitWindow); }
      set { Elements.SetBoolean(Keys.FitWindow, value); }
    }

    /// <summary>
    /// Gets or sets a value indicating whether to position the documents window
    /// in the center of the screen.
    /// </summary>
    public bool CenterWindow
    {
      get { return Elements.GetBoolean(Keys.CenterWindow); }
      set { Elements.SetBoolean(Keys.CenterWindow, value); }
    }

    /// <summary>
    /// Gets or sets a value indicating whether the windows title bar
    /// should display the document title taken from the Title entry of the document
    /// information dictionary. If false, the title bar should instead display the name
    /// of the PDF file containing the document.
    /// </summary>
    public bool DisplayDocTitle
    {
      get { return Elements.GetBoolean(Keys.DisplayDocTitle); }
      set { Elements.SetBoolean(Keys.DisplayDocTitle, value); }
    }

    /// <summary>
    /// The predominant reading order for text: LeftToRight or RightToLeft 
    /// (including vertical writing systems, such as Chinese, Japanese, and Korean).
    /// This entry has no direct effect on the documents contents or page numbering
    /// but can be used to determine the relative positioning of pages when displayed 
    /// side by side or printed n-up. Default value: LeftToRight.
    /// </summary>
    public PdfReadingDirection? Direction
    {
      get
      {
        switch (Elements.GetName(Keys.Direction))
        {
          case "L2R":
            return PdfReadingDirection.LeftToRight;

          case "R2L":
            return PdfReadingDirection.RightToLeft;
        }
        return null;
      }
      set
      {
        if (value.HasValue)
        {
          switch (value.Value)
          {
            case PdfReadingDirection.RightToLeft:
              Elements.SetName(Keys.Direction, "R2L");
              break;

            default:
              Elements.SetName(Keys.Direction, "L2R");
              break;
          }
        }
        else
          Elements.Remove(Keys.Direction);
      }
    }

    /// <summary>
    /// Predefined keys of this dictionary.
    /// </summary>
    internal sealed class Keys : KeysBase
    {
      /// <summary>
      /// (Optional) A flag specifying whether to hide the viewer applications tool
      ///  bars when the document is active. Default value: false.
      /// </summary>
      [KeyInfo(KeyType.Boolean | KeyType.Optional)]
      public const string HideToolbar = "/HideToolbar";

      /// <summary>
      /// (Optional) A flag specifying whether to hide the viewer applications
      /// menu bar when the document is active. Default value: false.
      /// </summary>
      [KeyInfo(KeyType.Boolean | KeyType.Optional)]
      public const string HideMenubar = "/HideMenubar";

      /// <summary>
      /// (Optional) A flag specifying whether to hide user interface elements in
      ///  the documents window (such as scroll bars and navigation controls),
      ///  leaving only the documents contents displayed. Default value: false.
      /// </summary>
      [KeyInfo(KeyType.Boolean | KeyType.Optional)]
      public const string HideWindowUI = "/HideWindowUI";

      /// <summary>
      /// (Optional) A flag specifying whether to resize the documents window to
      /// fit the size of the first displayed page. Default value: false.
      /// </summary>
      [KeyInfo(KeyType.Boolean | KeyType.Optional)]
      public const string FitWindow = "/FitWindow";

      /// <summary>
      /// (Optional) A flag specifying whether to position the documents window
      /// in the center of the screen. Default value: false.
      /// </summary>
      [KeyInfo(KeyType.Boolean | KeyType.Optional)]
      public const string CenterWindow = "/CenterWindow";

      /// <summary>
      /// (Optional; PDF 1.4) A flag specifying whether the windows title bar
      /// should display the document title taken from the Title entry of the document
      /// information dictionary. If false, the title bar should instead display the name
      /// of the PDF file containing the document. Default value: false.
      /// </summary>
      [KeyInfo(KeyType.Boolean | KeyType.Optional)]
      public const string DisplayDocTitle = "/DisplayDocTitle";

      /// <summary>
      /// (Optional) The documents page mode, specifying how to display the document on 
      /// exiting full-screen mode:
      ///   UseNone     Neither document outline nor thumbnail images visible
      ///   UseOutlines Document outline visible
      ///   UseThumbs   Thumbnail images visible
      ///   UseOC       Optional content group panel visible
      /// This entry is meaningful only if the value of the PageMode entry in the catalog 
      /// dictionary is FullScreen; it is ignored otherwise. Default value: UseNone.
      /// </summary>
      [KeyInfo(KeyType.Name | KeyType.Optional)]
      public const string NonFullScreenPageMode = "/NonFullScreenPageMode";

      /// <summary>
      /// (Optional; PDF 1.3) The predominant reading order for text:
      ///   L2R  Left to right
      ///   R2L  Right to left (including vertical writing systems, such as Chinese, Japanese, and Korean)
      /// This entry has no direct effect on the documents contents or page numbering
      /// but can be used to determine the relative positioning of pages when displayed 
      /// side by side or printed n-up. Default value: L2R.
      /// </summary>
      [KeyInfo(KeyType.Name | KeyType.Optional)]
      public const string Direction = "/Direction";

      /// <summary>
      /// (Optional; PDF 1.4) The name of the page boundary representing the area of a page
      /// to be displayed when viewing the document on the screen. The value is the key 
      /// designating the relevant page boundary in the page object. If the specified page
      /// boundary is not defined in the page object, its default value is used.
      /// Default value: CropBox.
      /// Note: This entry is intended primarily for use by prepress applications that
      /// interpret or manipulate the page boundaries as described in Section 10.10.1, Page Boundaries.
      /// Most PDF consumer applications disregard it.
      /// </summary>
      [KeyInfo(KeyType.Name | KeyType.Optional)]
      public const string ViewArea = "/ViewArea";

      /// <summary>
      /// (Optional; PDF 1.4) The name of the page boundary to which the contents of a page 
      /// are to be clipped when viewing the document on the screen. The value is the key 
      /// designating the relevant page boundary in the page object. If the specified page 
      /// boundary is not defined in the page object, its default value is used.
      /// Default value: CropBox.
      /// Note: This entry is intended primarily for use by prepress applications that
      /// interpret or manipulate the page boundaries as described in Section 10.10.1, Page Boundaries.
      /// Most PDF consumer applications disregard it.
      /// </summary>
      [KeyInfo(KeyType.Name | KeyType.Optional)]
      public const string ViewClip = "/ViewClip";

      /// <summary>
      /// (Optional; PDF 1.4) The name of the page boundary representing the area of a page
      /// to be rendered when printing the document. The value is the key designating the 
      /// relevant page boundary in the page object. If the specified page boundary is not 
      /// defined in the page object, its default value is used.
      /// Default value: CropBox.
      /// Note: This entry is intended primarily for use by prepress applications that
      /// interpret or manipulate the page boundaries as described in Section 10.10.1, Page Boundaries.
      /// Most PDF consumer applications disregard it.
      /// </summary>
      [KeyInfo(KeyType.Name | KeyType.Optional)]
      public const string PrintArea = "/PrintArea";

      /// <summary>
      /// (Optional; PDF 1.4) The name of the page boundary to which the contents of a page
      /// are to be clipped when printing the document. The value is the key designating the 
      /// relevant page boundary in the page object. If the specified page boundary is not
      /// defined in the page object, its default value is used.
      /// Default value: CropBox.
      /// Note: This entry is intended primarily for use by prepress applications that interpret
      /// or manipulate the page boundaries. Most PDF consumer applications disregard it.
      /// </summary>
      [KeyInfo(KeyType.Name | KeyType.Optional)]
      public const string PrintClip = "/PrintClip";

      /// <summary>
      /// (Optional; PDF 1.6) The page scaling option to be selected when a print dialog is
      /// displayed for this document. Valid values are None, which indicates that the print
      /// dialog should reflect no page scaling, and AppDefault, which indicates that 
      /// applications should use the current print scaling. If this entry has an unrecognized
      /// value, applications should use the current print scaling.
      /// Default value: AppDefault.
      /// Note: If the print dialog is suppressed and its parameters are provided directly
      /// by the application, the value of this entry should still be used.
      /// </summary>
      [KeyInfo(KeyType.Name | KeyType.Optional)]
      public const string PrintScaling = "/PrintScaling";

      /// <summary>
      /// Gets the KeysMeta for these keys.
      /// </summary>
      public static DictionaryMeta Meta
      {
        get
        {
          if (Keys.meta == null)
            Keys.meta = CreateMeta(typeof(Keys));
          return Keys.meta;
        }
      }
      static DictionaryMeta meta;
    }

    /// <summary>
    /// Gets the KeysMeta of this dictionary type.
    /// </summary>
    internal override DictionaryMeta Meta
    {
      get { return Keys.Meta; }
    }
  }
}