Class Controller

The class that controls the UI of a PdfView or a manually registered Windows.UI.Xaml.Controls.WebView

Inheritance
System.Object
Controller
Namespace: PSPDFKit.UI
Assembly: PSPDFKit.dll
Syntax
public sealed class Controller

Constructors

| Improve this Doc View Source

Controller(WebView, Uri)

Constructs a Controller to control an query the state of the UI.

Declaration
public Controller(WebView webView, Uri css)
Parameters
Type Name Description
Windows.UI.Xaml.Controls.WebView webView

A Windows.UI.Xaml.Controls.WebView that has loaded 'PSPDFKit.js'

System.Uri css

Optional URI of alternative CSS for 'PSPDFKit.js. See https://pspdfkit.com/guides/web/current/customizing-the-interface/css-customization/?search=css

Properties

| Improve this Doc View Source

AutoSave

The auto save mode. AutoSaveMode.

Declaration
public AutoSaveMode AutoSave { get; set; }
Property Value
Type Description
AutoSaveMode
| Improve this Doc View Source

ViewState

The current ViewState of the UI. Use with ShowDocumentWithViewStateAsync(DocumentSource, ViewState) to open a new document with the current ViewState.

Declaration
public ViewState ViewState { get; }
Property Value
Type Description
ViewState
| Improve this Doc View Source

ViewWatermark

A watermark which will be overlaid on the pages in the view. Set to null for no watermark. Usually the best place to set this is in PSPDFKit.UI.Controller.OnBeforeWatermark.

Declaration
public Watermark ViewWatermark { get; set; }
Property Value
Type Description
Watermark

Methods

| Improve this Doc View Source

DisableAnnotationPresetUpdatingAsync(Boolean)

If annotation preset updating is disabled then any changes to the defaults made by the user will not be preserved after they are finished with the annotation. In addition, the event OnAnnotationPresetUpdate will not be fired.

Declaration
public IAsyncAction DisableAnnotationPresetUpdatingAsync(bool disableUpdates)
Parameters
Type Name Description
System.Boolean disableUpdates

true disables preset updating. false enables preset updating.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

GetAnnotationPresetsAsync()

Get the current map of annotation presets.

Declaration
public IAsyncOperation<IDictionary<string, IAnnotation>> GetAnnotationPresetsAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Collections.Generic.IDictionary<System.String, IAnnotation>>

A map of annotation preset name to an instance of IAnnotation with the settings.

| Improve this Doc View Source

GetCurrentPageIndexAsync()

The page index of the page that's currently visible. If there is more than one page visible this will return the page that is using the most space in the viewport. The page index is zero-based and has a maximum value of the Document's TotalPageCount - 1.

Declaration
public IAsyncOperation<int> GetCurrentPageIndexAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Int32>

A page index

| Improve this Doc View Source

GetInkSignaturesAsync()

Gets current set of ink signatures as a list of Ink annotations. See IAnnotation

Declaration
public IAsyncOperation<IList<IAnnotation>> GetInkSignaturesAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Collections.Generic.IList<IAnnotation>>

A list of Ink annotations.

| Improve this Doc View Source

GetInteractionModeAsync()

Gets the currently set InteractionMode

Declaration
public IAsyncOperation<InteractionMode> GetInteractionModeAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<InteractionMode> InteractionMode
| Improve this Doc View Source

GetLayoutAsyncMode()

Gets the currently set LayoutMode.

Declaration
public IAsyncOperation<LayoutMode> GetLayoutAsyncMode()
Returns
Type Description
Windows.Foundation.IAsyncOperation<LayoutMode>

The LayoutMode

| Improve this Doc View Source

GetPdfDocument()

Get the currently opened Document

Declaration
public Document GetPdfDocument()
Returns
Type Description
Document
| Improve this Doc View Source

GetSelectedAnnotationAsync()

If an annotation is currently selected (and as well being either created or editable), this function will return the annotation.

Declaration
public IAsyncOperation<IAnnotation> GetSelectedAnnotationAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<IAnnotation>

The currently selected annotation or null if none is selected.

| Improve this Doc View Source

GetSidebarModeAsync()

Gets the currently set SidebarMode

Declaration
public IAsyncOperation<SidebarMode> GetSidebarModeAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<SidebarMode> SidebarMode
| Improve this Doc View Source

GetToolbarItems()

Gets the IToolbarItems shown.

Declaration
public IList<IToolbarItem> GetToolbarItems()
Returns
Type Description
System.Collections.Generic.IList<IToolbarItem>

Current list of toolbar items

| Improve this Doc View Source

GetZoomModeAsync()

Gets the currently set ZoomMode

Declaration
public IAsyncOperation<ZoomMode> GetZoomModeAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<ZoomMode> ZoomMode
| Improve this Doc View Source

IsKeepFirstSpreadAsSinglePageAsync()

Is the first spread always showing a single page?

Declaration
public IAsyncOperation<bool> IsKeepFirstSpreadAsSinglePageAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

true or false

| Improve this Doc View Source

IsPrintingAllowedAsync()

Is the printing button in the toolbar enabled or disabled?

Declaration
public IAsyncOperation<bool> IsPrintingAllowedAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

true or false

| Improve this Doc View Source

IsReadOnlyAsync()

Is read only mode is activated?

Declaration
public IAsyncOperation<bool> IsReadOnlyAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

true or false

| Improve this Doc View Source

IsShowingAnnotationsAsync()

Are annotations being rendered?

Declaration
public IAsyncOperation<bool> IsShowingAnnotationsAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

true or false

| Improve this Doc View Source

IsShowingToolbarAsync()

Is the toolbar displayed?

Declaration
public IAsyncOperation<bool> IsShowingToolbarAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

true or false

| Improve this Doc View Source

SetAnnotationPresetAsync(String, IAnnotation)

Set an annotation preset.

Declaration
public IAsyncAction SetAnnotationPresetAsync(string preset, IAnnotation settings)
Parameters
Type Name Description
System.String preset

The name of the preset.

IAnnotation settings

The annotation settings.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetAnnotationPresetsAsync(IDictionary<String, IAnnotation>)

Set the current map of annotation presets.

Declaration
public IAsyncAction SetAnnotationPresetsAsync(IDictionary<string, IAnnotation> presets)
Parameters
Type Name Description
System.Collections.Generic.IDictionary<System.String, IAnnotation> presets

A System.Collections.Generic.IDictionary<TKey, TValue> of presets.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetCurrentPageIndexAsync(Int32)

Display the page at the specified index.

Declaration
public IAsyncAction SetCurrentPageIndexAsync(int pageIndex)
Parameters
Type Name Description
System.Int32 pageIndex

The zero-based index of the page to be displayed.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetInkSignaturesAsync(IList<IAnnotation>)

Sets current set of ink signatures

Declaration
public IAsyncAction SetInkSignaturesAsync(IList<IAnnotation> inkSignatures)
Parameters
Type Name Description
System.Collections.Generic.IList<IAnnotation> inkSignatures
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetInteractionModeAsync(InteractionMode)

Sets the current InteractionMode and gives focus to the Windows.UI.Xaml.Controls.WebView. Use this method to set a specific interaction mode.

Declaration
public IAsyncAction SetInteractionModeAsync(InteractionMode interactionMode)
Parameters
Type Name Description
InteractionMode interactionMode InteractionMode
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetKeepFirstSpreadAsSinglePageAsync(Boolean)

When this is enabled, the first spread will always show a single page, even when PSPDFKit.LayoutMode.Double is enabled. This is useful for magazines that want to show a cover page before the regular content starts.

Declaration
public IAsyncAction SetKeepFirstSpreadAsSinglePageAsync(bool keepFirstSpreadAsSinglePage)
Parameters
Type Name Description
System.Boolean keepFirstSpreadAsSinglePage
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetLayoutModeAsync(LayoutMode)

Changes how the pages are be laid out in the document view.

Declaration
public IAsyncAction SetLayoutModeAsync(LayoutMode layoutMode)
Parameters
Type Name Description
LayoutMode layoutMode LayoutMode
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetPrintingAllowedAsync(Boolean)

Control whether or not the printing button in the toolbar should be disabled.

Declaration
public IAsyncAction SetPrintingAllowedAsync(bool allowPrinting)
Parameters
Type Name Description
System.Boolean allowPrinting
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetReadOnlyAsync(Boolean)

When the read only mode is activated, the Controller for creating, updating and deleting annotations will be completely hidden. In addition, the user will also no longer be able to select annotations.

Declaration
public IAsyncAction SetReadOnlyAsync(bool readOnly)
Parameters
Type Name Description
System.Boolean readOnly
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetSelectedAnnotationAsync(IAnnotation)

Selects an annotation in the user interface. If the annotation is null, the current selection will be cleared instead.

Declaration
public IAsyncAction SetSelectedAnnotationAsync(IAnnotation annotation)
Parameters
Type Name Description
IAnnotation annotation

The annotation you want to set as selected. If null the current selection will be cleared instead.

Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetShowAnnotationsAsync(Boolean)

When this is set to false, annotations will no longer be rendered. This option can alo be set to false, when ReadOnly mode is enabled.

Declaration
public IAsyncAction SetShowAnnotationsAsync(bool showAnnotations)
Parameters
Type Name Description
System.Boolean showAnnotations
Returns
Type Description
Windows.Foundation.IAsyncAction
See Also
| Improve this Doc View Source

SetShowToolbarAsync(Boolean)

Set this to true if you want a toolbar for navigation and annotation controls or false if you don't.

Declaration
public IAsyncAction SetShowToolbarAsync(bool showToolbar)
Parameters
Type Name Description
System.Boolean showToolbar
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetSidebarModeAsync(SidebarMode)

Sets the current SidebarMode. Use this method to set a specific sidebar mode.

Declaration
public IAsyncAction SetSidebarModeAsync(SidebarMode sidebarMode)
Parameters
Type Name Description
SidebarMode sidebarMode SidebarMode
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetToolbarItemsAsync(IList<IToolbarItem>)

Sets the IToolbarItems to be show. This will overwrite any items currently held by the toolbar. If the view is not initialized, the item will be cached and set when the view is ready.

Declaration
public IAsyncAction SetToolbarItemsAsync(IList<IToolbarItem> toolbarItems)
Parameters
Type Name Description
System.Collections.Generic.IList<IToolbarItem> toolbarItems
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

SetZoomModeAsync(ZoomMode)

Sets the current zoom factor. Use this method to set a specific zoom mode.

Declaration
public IAsyncAction SetZoomModeAsync(ZoomMode zoomMode)
Parameters
Type Name Description
ZoomMode zoomMode ZoomMode
Returns
Type Description
Windows.Foundation.IAsyncAction
| Improve this Doc View Source

ShowDocumentAsync(DocumentSource)

Display the document in the UI. Note that this always resets CurrentPageIndex to 0.

Declaration
public IAsyncOperation<Document> ShowDocumentAsync(DocumentSource source)
Parameters
Type Name Description
DocumentSource source

The DocumentSource representing the PDF.

Returns
Type Description
Windows.Foundation.IAsyncOperation<Document>

A Document representing the opened PDF.

| Improve this Doc View Source

ShowDocumentWithViewStateAsync(DocumentSource, ViewState)

Display the document in the UI with all view options such as if annotations are show or not, and so on, reset to their default setting. Note that this always ignores CurrentPageIndex and sets it to 0.

Declaration
public IAsyncOperation<Document> ShowDocumentWithViewStateAsync(DocumentSource source, ViewState viewState)
Parameters
Type Name Description
DocumentSource source

The DocumentSource representing the PDF.

ViewState viewState

The ViewState to use when opening the PDF.

Returns
Type Description
Windows.Foundation.IAsyncOperation<Document>

A Document representing the opened PDF.

Events

| Improve this Doc View Source

OnAnnotationPresetUpdate

Invoked when an annotation preset is updated if DisableAnnotationPresetUpdatingAsync(Boolean) is not set to False.

Declaration
public event TypedEventHandler<Controller, AnnotationPresetUpdate> OnAnnotationPresetUpdate
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Controller, AnnotationPresetUpdate>
| Improve this Doc View Source

OnAnnotationSelectionChanged

Invoked when an annotation is being selected or unselected.

Declaration
public event TypedEventHandler<Controller, IAnnotation> OnAnnotationSelectionChanged
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Controller, IAnnotation>
| Improve this Doc View Source

OnCurrentPageChanged

Invoked when the currently displayed page changes. The page index of the page that's currently visible. If there is more than one page visible it is the page that is using the most space in the viewport.

Declaration
public event TypedEventHandler<Controller, int> OnCurrentPageChanged
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Controller, System.Int32>
| Improve this Doc View Source

OnPrint

Invoked when the print putton is clicked on the toolbar in the UI.

Declaration
public event TypedEventHandler<Controller, Document> OnPrint
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Controller, Document>
| Improve this Doc View Source

OnRequestPassword

Invoked when a password is required to open a PDF.

Declaration
public event TypedEventHandler<Controller, PasswordEventArgs> OnRequestPassword
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Controller, PasswordEventArgs>