Class SfPdfViewer
Represents a control that displays a PDF document.
Implements
Inherited Members
Namespace: Syncfusion.Maui.PdfViewer
Assembly: Syncfusion.Maui.PdfViewer.dll
Syntax
public class SfPdfViewer : SfView, IDrawableLayout, IDrawable, IAbsoluteLayout, ILayout, IView, IElement, ITransform, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISafeAreaView, IPadding, IVisualTreeElement
Constructors
SfPdfViewer()
Initializes a new instance of the SfPdfViewer class.
Declaration
public SfPdfViewer()
Fields
DocumentSourceProperty
Backing store for the DocumentSource property.
Declaration
public static readonly BindableProperty DocumentSourceProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
EnableDocumentLinkNavigationProperty
Backing store for EnableDocumentLinkNavigation property.
Declaration
public static readonly BindableProperty EnableDocumentLinkNavigationProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
EnableHyperlinkNavigationProperty
Backing store for EnableHyperlinkNavigation property.
Declaration
public static readonly BindableProperty EnableHyperlinkNavigationProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
HorizontalOffsetProperty
Backing store for HorizontalOffset property.
Declaration
public static readonly BindableProperty HorizontalOffsetProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
IsOutlineViewVisibleProperty
Backing store for the IsOutlineViewVisible property.
Declaration
public static readonly BindableProperty IsOutlineViewVisibleProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
MaxZoomFactorProperty
Backing store for the MaxZoomFactor property.
Declaration
public static readonly BindableProperty MaxZoomFactorProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
MinZoomFactorProperty
Backing store for the MinZoomFactor property.
Declaration
public static readonly BindableProperty MinZoomFactorProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
PageCountProperty
Backing store for the PageCount property.
Declaration
public static readonly BindableProperty PageCountProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
PageNumberProperty
Backing store for the PageNumber property.
Declaration
public static readonly BindableProperty PageNumberProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
ShowScrollHeadProperty
Backing store for ShowScrollHead property.
Declaration
public static readonly BindableProperty ShowScrollHeadProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
TextSearchSettingsProperty
Backing store for TextSearchSettings property.
Declaration
public static readonly BindableProperty TextSearchSettingsProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
VerticalOffsetProperty
Backing store for VerticalOffset property.
Declaration
public static readonly BindableProperty VerticalOffsetProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
ZoomFactorProperty
Backing store for the ZoomFactorProperty property.
Declaration
public static readonly BindableProperty ZoomFactorProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Properties
DocumentOutline
Gets the oultline for the document.
Declaration
public IReadOnlyList<OutlineElement> DocumentOutline { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<OutlineElement> | The outlines in the document. |
DocumentSource
Gets or sets the PDF document source as System.IO.Stream or byte array.
Declaration
public object DocumentSource { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
EnableDocumentLinkNavigation
Gets or sets a value that indicates whether document link annotations (TOC) in the PDF can be interacted with.
Declaration
public bool EnableDocumentLinkNavigation { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
EnableHyperlinkNavigation
Gets or sets the value that indicates whether the hyperlink navigation can be performed or not.
Declaration
public bool EnableHyperlinkNavigation { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is true. |
GoToFirstPageCommand
Gets the value that represents the go to first page command.
Declaration
public ICommand GoToFirstPageCommand { get; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand |
GoToLastPageCommand
Gets the value that represents the go to last page command.
Declaration
public ICommand GoToLastPageCommand { get; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand |
GoToNextPageCommand
Gets the value that represents the go to next page command.
Declaration
public ICommand GoToNextPageCommand { get; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand |
GoToPageCommand
Gets the value that represents the go to specific page command.
Declaration
public ICommand GoToPageCommand { get; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand |
GoToPreviousPageCommand
Gets the value that represents the go to previous page command.
Declaration
public ICommand GoToPreviousPageCommand { get; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand |
HorizontalOffset
Returns the current horizontal scrolled position of the SfPdfViewer.
Declaration
public Nullable<double> HorizontalOffset { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> |
IsOutlineViewVisible
Gets or sets a value indicating whether the outline view is visible.
Declaration
public bool IsOutlineViewVisible { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
LoadDocumentCommand
Gets the command that loads a PDF document when executed.
Declaration
public ICommand LoadDocumentCommand { get; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand |
MaxZoomFactor
Get or sets the maximum allowed zoom factor.
Declaration
public double MaxZoomFactor { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The default value is 4. The value should not be lower than MinZoomFactor. |
MinZoomFactor
Get or sets the minimum allowed zoom factor.
Declaration
public double MinZoomFactor { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The default value is 0.25 and 1 for desktop and mobile platforms respectively. The value should not exceed the MaxZoomFactor. |
PageCount
Returns the total number of pages in a document.
Declaration
public int PageCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
PageNumber
Returns the current page number.
Declaration
public int PageNumber { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
ScrollToOffsetCommand
Gets the value that represents the scroll to specific offset command.
Declaration
public ICommand ScrollToOffsetCommand { get; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand |
SearchTextCommand
Gets the command to search a text in the PDF document asynchronously.
Declaration
public ICommand SearchTextCommand { get; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand |
ShowScrollHead
Gets or sets the value indicates whether or not the scroll head can be shown.
Declaration
public bool ShowScrollHead { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is true. |
Remarks
This property is applicable only for the mobile platforms.
TextSearchSettings
Represents and allows for modification of the text search settings.
Declaration
public TextSearchSettings TextSearchSettings { get; }
Property Value
Type | Description |
---|---|
TextSearchSettings |
VerticalOffset
Returns the current vertical scrolled position of the SfPdfViewer.
Declaration
public Nullable<double> VerticalOffset { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> |
ZoomFactor
Gets or sets the zoom factor for the document loaded in the SfPdfViewer.
Declaration
public double ZoomFactor { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The default value is 1. The value can be set between MinZoomFactor and MaxZoomFactor. If anything set beyond the limit, the value will be clamped. |
Methods
GoToFirstPage()
Jumps to the first page of a document.
Declaration
public void GoToFirstPage()
GoToLastPage()
Jumps to the last page of a document.
Declaration
public void GoToLastPage()
GoToNextPage()
Jumps to the next page of a document.
Declaration
public void GoToNextPage()
GoToOutlineElement(OutlineElement)
Navigates to the location of the given outline element.
Declaration
public void GoToOutlineElement(OutlineElement outlineElement)
Parameters
Type | Name | Description |
---|---|---|
OutlineElement | outlineElement |
GoToPage(Int32)
Jumps to the specified page in a document.
Declaration
public void GoToPage(int pageNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pageNumber | The number of the page to which the control should go. |
GoToPreviousPage()
Jumps to the previous page of a document.
Declaration
public void GoToPreviousPage()
LoadDocument(Byte[], String, Nullable<FlattenOptions>)
Loads the PDF document from the specified bytes.
Declaration
public void LoadDocument(byte[] documentBytes, string password = null, Nullable<FlattenOptions> flattenOptions)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | documentBytes | The document as byte array |
System.String | password | Password for the document. It is required to open a password protected document. |
System.Nullable<FlattenOptions> | flattenOptions | The option that represents whether annotations or form fields should be flattened. |
LoadDocument(Stream, String, Nullable<FlattenOptions>)
Loads the PDF document from the specified stream.
Declaration
public void LoadDocument(Stream documentStream, string password = null, Nullable<FlattenOptions> flattenOptions)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | documentStream | The document stream. |
System.String | password | Password for the document. It is required to open a password protected document. |
System.Nullable<FlattenOptions> | flattenOptions | The option that represents whether annotations or form fields should be flattened. |
LoadDocumentAsync(Byte[], String, Nullable<FlattenOptions>, CancellationTokenSource)
Loads the PDF document asynchronously from the specified bytes.
Declaration
public Task LoadDocumentAsync(byte[] documentBytes, string password = null, Nullable<FlattenOptions> flattenOptions, CancellationTokenSource cancellationTokenSource = null)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | documentBytes | The document as byte array. |
System.String | password | Password for the document. It is required to open a password protected document. |
System.Nullable<FlattenOptions> | flattenOptions | The option that represents whether annotations or form fields should be flattened. |
System.Threading.CancellationTokenSource | cancellationTokenSource | The cancellation token source for cancelling the task. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Returns the task |
LoadDocumentAsync(Stream, String, Nullable<FlattenOptions>, CancellationTokenSource)
Loads the PDF document asynchronously from the specified stream.
Declaration
public Task LoadDocumentAsync(Stream documentStream, string password = null, Nullable<FlattenOptions> flattenOptions, CancellationTokenSource cancellationTokenSource = null)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | documentStream | The document stream. |
System.String | password | Password for the document. It is required to open a password protected document. |
System.Nullable<FlattenOptions> | flattenOptions | The option that represents whether annotations or form fields should be flattened. |
System.Threading.CancellationTokenSource | cancellationTokenSource | The cancellation token source for cancelling the task. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Returns the task |
ScrollToOffset(Double, Double)
Scrolls the content to the specified offset.
Declaration
public void ScrollToOffset(double horizontalOffset, double verticalOffset)
Parameters
Type | Name | Description |
---|---|---|
System.Double | horizontalOffset | The value to which the control scrolls horizontally. The value is measured in device-independent units. |
System.Double | verticalOffset | The value to which the control scrolls vertically. The value is measured in device-independent units. |
SearchTextAsync(String, TextSearchOptions, CancellationTokenSource)
Finds and highlights all occurrences of the given text in the PDF document asynchronously.
Declaration
public Task<TextSearchResult> SearchTextAsync(string text, TextSearchOptions searchOption, CancellationTokenSource cancellationTokenSource = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text or keyword to be searched. |
TextSearchOptions | searchOption | The constant to specify the text search options. |
System.Threading.CancellationTokenSource | cancellationTokenSource | The cancellation token to cancel the current search progress. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TextSearchResult> | Provides the search result obtained from searching a given text. |
UnloadDocument()
Unloads the current PDF document.
Declaration
public void UnloadDocument()
UnloadDocumentAsync()
Unloads the current PDF document asynchronously.
Declaration
public Task UnloadDocumentAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Events
DocumentLoaded
Occurs when a PDF document is loaded.
Declaration
public event EventHandler<EventArgs> DocumentLoaded
Event Type
Type | Description |
---|---|
System.EventHandler<System.EventArgs> |
DocumentLoadFailed
Occurs when the PDF Viewer fails to load a PDF document.
Declaration
public event EventHandler<DocumentLoadFailedEventArgs> DocumentLoadFailed
Event Type
Type | Description |
---|---|
System.EventHandler<DocumentLoadFailedEventArgs> |
DocumentUnloaded
Occurs when a PDF document is unloaded.
Declaration
public event EventHandler<EventArgs> DocumentUnloaded
Event Type
Type | Description |
---|---|
System.EventHandler<System.EventArgs> |
HyperlinkClicked
Occurs when hyperlink is clicked or tapped.
Declaration
public event EventHandler<HyperlinkClickedEventArgs> HyperlinkClicked
Event Type
Type | Description |
---|---|
System.EventHandler<HyperlinkClickedEventArgs> |
PasswordRequested
Occurs when a security password is required to open a PDF document.
Declaration
public event EventHandler<PasswordRequestedEventArgs> PasswordRequested
Event Type
Type | Description |
---|---|
System.EventHandler<PasswordRequestedEventArgs> |
TextSearchProgress
Occurs when the text search is in progress.
Declaration
public event EventHandler<TextSearchProgressEventArgs> TextSearchProgress
Event Type
Type | Description |
---|---|
System.EventHandler<TextSearchProgressEventArgs> |