PdfViewer Class
Definition
Keyboard nudging of the selected annotation and deselection from presses outside the pages.
public class PdfViewer
Constructors
| Name | Description |
|---|---|
| PdfViewer | No summary available. |
PdfViewer Constructor
public PdfViewer()
Methods
| Name | Description |
|---|---|
| AddBookmark | Adds a bookmark for the given 1-based page. No-op when the page is out of range or already bookmarked. Returns if a bookmark was added. |
| AddHandler (2 overloads) | Adds a handler for the specified routed event. Inherited from Interactive. |
| AddStampAsync | No summary available. |
| AddStickyNoteAsync | No summary available. |
| ApplyStyling | Applies styling to the control if the control is initialized and styling is not already applied. Inherited from StyledElement. |
| ApplyTemplate | Creates the visual children of the control, if necessary Inherited from TemplatedControl. |
| Arrange | Arranges the control and its children. Inherited from Layoutable. |
| BeginInit | Inherited from StyledElement. |
| Bind (8 overloads) | Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase. Inherited from AvaloniaObject. |
| CheckAccess | Returns a value indicating whether the current thread is the UI thread. Inherited from AvaloniaObject. |
| ClearError | Clears Avalonia.Controls.PdfViewer.ErrorMessage. An open document stays open; after a failed load the viewer returns to its empty state. The template's dismiss buttons call this. |
| ClearSearch | Clears the current search query, results, and highlights. |
| ClearSelection | Clears the current text selection. |
| ClearValue (4 overloads) | Clears a Avalonia.AvaloniaProperty's local value. Inherited from AvaloniaObject. |
| CloseDocument | Closes the current document. |
| CoerceValue | Coerces the specified Avalonia.AvaloniaProperty. Inherited from AvaloniaObject. |
| CopySelectionToClipboard | Copies the current selection to the clipboard. |
| DefaultStampColorFor | The colour a stamp is drawn in when Avalonia.Controls.PdfViewer.StampColor is not set. |
| EndInit | Inherited from StyledElement. |
| Equals | Compares two objects using reference equality. Inherited from AvaloniaObject. |
| FindNext | Advances to the next search match (wraps around). |
| FindPrevious | Moves to the previous search match (wraps around). |
| FitHeight | Fits the current page height to the view. |
| FitPage | Fits the entire page to the view. |
| FitWidth | Fits the page width to the view. |
| Focus | Focuses the control. Inherited from InputElement. |
| FocusViewer | Focuses the PDF viewer control for keyboard navigation. Call this after external interactions (like opening a file) to enable keyboard navigation. |
| FormatStampDate | Formats date the way a stamp's date line is drawn. |
| GetAnnotationsAsync | Gets the annotations on a page (0-based index). Returns an empty list when no document is loaded or the index is out of range. |
| GetBaseValue | Inherited from AvaloniaObject. |
| GetFlowDirection | Gets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control. Inherited from Visual. |
| GetHashCode | Gets the hash code for the object. Inherited from AvaloniaObject. |
| GetIsHoldingEnabled | Inherited from InputElement. |
| GetIsHoldWithMouseEnabled | Inherited from InputElement. |
| GetIsTemplateFocusTarget | Gets the value of the IsTemplateFocusTargetProperty attached property on a control. Inherited from TemplatedControl. |
| GetOutline | Gets the document outline (bookmarks). |
| GetPageLabel | The page's label from the document's /PageLabels ("iv", "A-2"), or null when the document defines none. pageNumber is 1-based. |
| GetPageTextAsync | Extracts the plain text of a single page (0-based index). Returns an empty string when no document is loaded or the index is out of range. |
| GetSelectedText | Gets the currently selected text. |
| GetTextAsync | Extracts the plain text of the whole document, one page per element. |
| GetValue (3 overloads) | Gets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject. |
| GoToBookmark | Navigates to a bookmark's target: its full destination (page plus position) when it has one, else its page. Returns true if the bookmark has a page target. |
| GoToPage | Navigates to a specific page. |
| HighlightSelectionAsync | No summary available. |
| InvalidateArrange | Invalidates the arrangement of the control and queues a new layout pass. Inherited from Layoutable. |
| InvalidateMeasure | Invalidates the measurement of the control and queues a new layout pass. Inherited from Layoutable. |
| InvalidateVisual | Invalidates the visual and queues a repaint. Inherited from Visual. |
| IsAnimating | Checks whether a Avalonia.AvaloniaProperty is animating. Inherited from AvaloniaObject. |
| IsPageBookmarked | Returns whether the given 1-based page currently has a bookmark. |
| IsSet | Checks whether a Avalonia.AvaloniaProperty is set on this object. Inherited from AvaloniaObject. |
| LoadDocumentAsync (3 overloads) | Loads a PDF document from a stream. The stream is read once, from its current position (a seekable stream left at its end is read from the start), and is never disposed or kept: the viewer holds its own copy of the bytes, so the caller may dispose the stream as soon as this call returns. The document has no path; save with Avalonia.Controls.PdfViewer.SaveDocumentAsync(string) or Save As. |
| Measure | Carries out a measure of the control. Inherited from Layoutable. |
| NavigateTo | Navigates to a link destination: the page, and in the continuous view modes the position on it (an /XYZ or /FitH target lands with its top edge at the top of the viewport, not the page top); an /XYZ zoom that is set is applied first. Returns true if it was an in-document page destination that could be resolved. |
| NextPage | Navigates to the next page (or next spread in two-page mode). |
| Open | Opens a document via the file picker (fire-and-forget). See Avalonia.Controls.PdfViewer.OpenAsync(System.Threading.CancellationToken). |
| OpenAsync | Asks the user for a PDF and loads it. Raises Avalonia.Controls.PdfViewer.OpenRequested first; when the host does not handle it, the platform file picker of the owning Avalonia.Controls.TopLevel is used. A file with a local path is opened by path (so Avalonia.Controls.PdfViewer.Source is set and in-place saving works); otherwise it is read through a stream. |
| OpenMoreOptions | Opens the More Options flyout programmatically. |
| PreviousPage | Navigates to the previous page (or previous spread in two-page mode). |
| Prints the current document (fire-and-forget). Errors surface via Avalonia.Controls.PdfViewer.ErrorMessage. | |
| PrintAsync | Prints the current document. Raises Avalonia.Controls.PdfViewer.PrintRequested first; if the handler marks it handled nothing else happens, otherwise the Avalonia.Controls.PdfViewer.PrintService shows the system print dialog. No-op when no document is loaded. |
| RaiseEvent | Raises a routed event. Inherited from Interactive. |
| RedactSelectionAsync | No summary available. |
| Redo | Re-applies the most recently undone edit, if any. |
| RedoAsync | Re-applies the most recently undone edit and completes when the document has been updated. |
| RemoveBookmark | Removes the bookmark for the given 1-based page. Returns if a bookmark was removed. |
| RemoveHandler (2 overloads) | Removes a handler for the specified routed event. Inherited from Interactive. |
| Render | Renders the visual to a Avalonia.Media.DrawingContext. Inherited from Visual. |
| RenderPageToImageAsync | Renders a page (0-based index) to a bitmap at the given scale (1.0 == 100%). Returns null when no document is loaded or the index is out of range. The caller owns the returned bitmap and should dispose it. |
| ResetZoom | Resets zoom to 100%. |
| Save | Saves the document in place (fire-and-forget); a failure, including a stream-backed document with no path, is reported through Avalonia.Controls.PdfViewer.ErrorMessage. See Avalonia.Controls.PdfViewer.SaveAsync. |
| SaveAs | Saves via the save picker (fire-and-forget). See Avalonia.Controls.PdfViewer.SaveAsAsync(System.Threading.CancellationToken). |
| SaveAsAsync | Writes the document, with its annotation edits, to a file chosen by the user. Raises Avalonia.Controls.PdfViewer.SaveAsRequested first; when the host does not handle it, the platform save picker of the owning Avalonia.Controls.TopLevel is used. Choosing the open file saves in place (see Avalonia.Controls.PdfViewer.SaveAsync); choosing another local path writes it and the viewer switches to that file, keeping the current page. |
| SaveAsync | Saves the document in place to its original Avalonia.Controls.PdfViewer.Source path, including any annotation edits. No-op when Avalonia.Controls.PdfViewer.AllowDocumentSaving is false or when no document is loaded. A document loaded from a stream or byte array has no path to save to: use Avalonia.Controls.PdfViewer.SaveDocumentAsync(System.IO.Stream) or Avalonia.Controls.PdfViewer.SaveAsAsync(System.Threading.CancellationToken) for those. |
| SaveDocumentAsync (2 overloads) | Saves the document (with all annotations) to a stream. |
| SearchAsync (2 overloads) | Searches for text in the document and publishes the results (Avalonia.Controls.PdfViewer.SearchResults, find next/previous, Avalonia.Controls.PdfViewer.SearchCompleted). A failure is reported through Avalonia.Controls.PdfViewer.ErrorMessage and returns an empty list. |
| SelectAll | Selects all text on the current page. |
| SetCurrentValue (2 overloads) | Sets the value of a dependency property without changing its value source. Inherited from AvaloniaObject. |
| SetFlowDirection | Sets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control. Inherited from Visual. |
| SetIsHoldingEnabled | Inherited from InputElement. |
| SetIsHoldWithMouseEnabled | Inherited from InputElement. |
| SetIsTemplateFocusTarget | Sets the value of the IsTemplateFocusTargetProperty attached property on a control. Inherited from TemplatedControl. |
| SetValue (3 overloads) | Sets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject. |
| Share | Shares the current document (fire-and-forget). Errors surface via Avalonia.Controls.PdfViewer.ErrorMessage. |
| ShareAsync | Shares the current document. Raises Avalonia.Controls.PdfViewer.ShareRequested first; if the handler marks it handled nothing else happens, otherwise the Avalonia.Controls.PdfViewer.ShareService shows the system share sheet. No-op when no document is loaded. |
| SquigglySelectionAsync | No summary available. |
| StampNameForLabel | Stamp name for a label: the label without spaces, so standard labels map to standard names. |
| StampStyleDisplayName | The English name of a style as shown in the Stamp dropdown (see Avalonia.Controls.PdfViewer.Strings for other languages). |
| StrikeoutSelectionAsync | No summary available. |
| ToggleBookmark | Toggles the bookmark for the given 1-based page. Returns the new state ( when the page is now bookmarked). |
| ToggleBookmarkCurrentPage | Toggles the bookmark for the current page (the ⌘D / Ctrl+D action). |
| TryGetResource | Inherited from StyledElement. |
| UnderlineSelectionAsync | No summary available. |
| Undo | Reverts the most recent edit, if any. |
| UndoAsync | Reverts the most recent edit and completes when the document has been updated. |
| UpdateLayout | Executes a layout pass. Inherited from Layoutable. |
| UpdateStickyNoteAsync | No summary available. |
| VerifyAccess | Checks that the current thread is the UI thread and throws if not. Inherited from AvaloniaObject. |
| ZoomIn | Zooms in to the next preset level. |
| ZoomOut | Zooms out to the previous preset level. |
AddBookmark Method
Adds a bookmark for the given 1-based page. No-op when the page is out of range or already bookmarked. Returns if a bookmark was added.
public bool AddBookmark(int pageNumber)
Parameters
pageNumber int
Returns
bool
AddStampAsync Method
public System.Threading.Tasks.Task<int> AddStampAsync(int pageIndex, string label, double pdfX, double pdfY, Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor> color, Nullable<Avalonia.Controls.PdfStampStyle> style, Nullable<bool> includeDate)
Parameters
pageIndex int
label string
pdfX double
pdfY double
color Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor>
style Nullable<Avalonia.Controls.PdfStampStyle>
includeDate Nullable<bool>
Returns
System.Threading.Tasks.Task<int>
AddStickyNoteAsync Method
public System.Threading.Tasks.Task<int> AddStickyNoteAsync(int pageIndex, double pdfX, double pdfY, string text, Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor> color)
Parameters
pageIndex int
pdfX double
pdfY double
text string
color Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor>
Returns
System.Threading.Tasks.Task<int>
ClearError Method
Clears Avalonia.Controls.PdfViewer.ErrorMessage. An open document stays open; after a failed load the viewer returns to its empty state. The template's dismiss buttons call this.
public void ClearError()
ClearSearch Method
Clears the current search query, results, and highlights.
public void ClearSearch()
ClearSelection Method
Clears the current text selection.
public void ClearSelection()
CloseDocument Method
Closes the current document.
public void CloseDocument()
CopySelectionToClipboard Method
Copies the current selection to the clipboard.
public System.Threading.Tasks.Task CopySelectionToClipboard()
Returns
System.Threading.Tasks.Task
DefaultStampColorFor Method
The colour a stamp is drawn in when Avalonia.Controls.PdfViewer.StampColor is not set.
public Avalonia.Controls.Pdf.Core.PdfAnnotationColor DefaultStampColorFor(string label)
Parameters
label string
Returns
FindNext Method
Advances to the next search match (wraps around).
public void FindNext()
FindPrevious Method
Moves to the previous search match (wraps around).
public void FindPrevious()
FitHeight Method
Fits the current page height to the view.
public void FitHeight()
FitPage Method
Fits the entire page to the view.
public void FitPage()
FitWidth Method
Fits the page width to the view.
public void FitWidth()
FocusViewer Method
Focuses the PDF viewer control for keyboard navigation. Call this after external interactions (like opening a file) to enable keyboard navigation.
public void FocusViewer()
FormatStampDate Method
Formats date the way a stamp's date line is drawn.
public string FormatStampDate(DateTime date)
Parameters
date DateTime
Returns
string
GetAnnotationsAsync Method
Gets the annotations on a page (0-based index). Returns an empty list when no document is loaded or the index is out of range.
public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Pdf.Core.PdfAnnotationInfo>> GetAnnotationsAsync(int pageIndex, System.Threading.CancellationToken cancellationToken)
Parameters
pageIndex int
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Pdf.Core.PdfAnnotationInfo>>
GetOutline Method
Gets the document outline (bookmarks).
public System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Pdf.Core.PdfBookmark> GetOutline()
Returns
System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Pdf.Core.PdfBookmark>
GetPageLabel Method
The page's label from the document's /PageLabels ("iv", "A-2"), or null when the document
defines none. pageNumber is 1-based.
public string GetPageLabel(int pageNumber)
Parameters
pageNumber int
Returns
string
GetPageTextAsync Method
Extracts the plain text of a single page (0-based index). Returns an empty string when no document is loaded or the index is out of range.
public System.Threading.Tasks.Task<string> GetPageTextAsync(int pageIndex, System.Threading.CancellationToken cancellationToken)
Parameters
pageIndex int
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task<string>
GetSelectedText Method
Gets the currently selected text.
public string GetSelectedText()
Returns
string
The selected text, or null if no selection.
GetTextAsync Method
Extracts the plain text of the whole document, one page per element.
public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<string>> GetTextAsync(System.Threading.CancellationToken cancellationToken)
Parameters
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<string>>
GoToBookmark Method
Navigates to a bookmark's target: its full destination (page plus position) when it has
one, else its page. Returns true if the bookmark has a page target.
public bool GoToBookmark(Avalonia.Controls.Pdf.Core.PdfBookmark bookmark)
Parameters
bookmark Avalonia.Controls.Pdf.Core.PdfBookmark
Returns
bool
GoToPage Method
Navigates to a specific page.
public void GoToPage(int pageNumber)
Parameters
pageNumber int
HighlightSelectionAsync Method
public System.Threading.Tasks.Task<int> HighlightSelectionAsync(Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor> color)
Parameters
color Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor>
Returns
System.Threading.Tasks.Task<int>
IsPageBookmarked Method
Returns whether the given 1-based page currently has a bookmark.
public bool IsPageBookmarked(int pageNumber)
Parameters
pageNumber int
Returns
bool
LoadDocumentAsync overloads
LoadDocumentAsync Method
Loads a PDF document from a stream. The stream is read once, from its current position (a seekable stream left at its end is read from the start), and is never disposed or kept: the viewer holds its own copy of the bytes, so the caller may dispose the stream as soon as this call returns. The document has no path; save with Avalonia.Controls.PdfViewer.SaveDocumentAsync(string) or Save As.
public System.Threading.Tasks.Task LoadDocumentAsync(System.IO.Stream stream, string password)
Parameters
stream System.IO.Stream
password string
Returns
System.Threading.Tasks.Task
LoadDocumentAsync Method
public System.Threading.Tasks.Task LoadDocumentAsync(ReadOnlyMemory<byte> data, string password)
Parameters
data ReadOnlyMemory<byte>
password string
Returns
System.Threading.Tasks.Task
LoadDocumentAsync Method
Loads a PDF document from a file path.
public System.Threading.Tasks.Task LoadDocumentAsync(string path, string password)
Parameters
path string
password string
Returns
System.Threading.Tasks.Task
NavigateTo Method
Navigates to a link destination: the page, and in the continuous view modes the position
on it (an /XYZ or /FitH target lands with its top edge at the top of the viewport, not the
page top); an /XYZ zoom that is set is applied first. Returns true if it was an
in-document page destination that could be resolved.
public bool NavigateTo(Avalonia.Controls.Pdf.Core.PdfLinkDestination destination)
Parameters
destination Avalonia.Controls.Pdf.Core.PdfLinkDestination
Returns
bool
NextPage Method
Navigates to the next page (or next spread in two-page mode).
public void NextPage()
Open Method
Opens a document via the file picker (fire-and-forget). See Avalonia.Controls.PdfViewer.OpenAsync(System.Threading.CancellationToken).
public void Open()
OpenAsync Method
Asks the user for a PDF and loads it. Raises Avalonia.Controls.PdfViewer.OpenRequested first; when the host does not handle it, the platform file picker of the owning Avalonia.Controls.TopLevel is used. A file with a local path is opened by path (so Avalonia.Controls.PdfViewer.Source is set and in-place saving works); otherwise it is read through a stream.
public System.Threading.Tasks.Task OpenAsync(System.Threading.CancellationToken cancellationToken)
Parameters
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task
Exceptions
OpenMoreOptions Method
Opens the More Options flyout programmatically.
public void OpenMoreOptions()
PreviousPage Method
Navigates to the previous page (or previous spread in two-page mode).
public void PreviousPage()
Print Method
Prints the current document (fire-and-forget). Errors surface via Avalonia.Controls.PdfViewer.ErrorMessage.
public void Print()
PrintAsync Method
Prints the current document. Raises Avalonia.Controls.PdfViewer.PrintRequested first; if the handler marks it handled nothing else happens, otherwise the Avalonia.Controls.PdfViewer.PrintService shows the system print dialog. No-op when no document is loaded.
public System.Threading.Tasks.Task PrintAsync(Avalonia.Controls.Pdf.Services.PrintOptions options, System.Threading.CancellationToken cancellationToken)
Parameters
options Avalonia.Controls.Pdf.Services.PrintOptions
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task
Exceptions
RedactSelectionAsync Method
public System.Threading.Tasks.Task<int> RedactSelectionAsync(Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor> color)
Parameters
color Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor>
Returns
System.Threading.Tasks.Task<int>
Redo Method
Re-applies the most recently undone edit, if any.
public void Redo()
RedoAsync Method
Re-applies the most recently undone edit and completes when the document has been updated.
public System.Threading.Tasks.Task RedoAsync()
Returns
System.Threading.Tasks.Task
RemoveBookmark Method
Removes the bookmark for the given 1-based page. Returns if a bookmark was removed.
public bool RemoveBookmark(int pageNumber)
Parameters
pageNumber int
Returns
bool
RenderPageToImageAsync Method
Renders a page (0-based index) to a bitmap at the given scale (1.0 == 100%).
Returns null when no document is loaded or the index is out of range.
The caller owns the returned bitmap and should dispose it.
public System.Threading.Tasks.Task<Avalonia.Media.Imaging.Bitmap> RenderPageToImageAsync(int pageIndex, double scale, System.Threading.CancellationToken cancellationToken)
Parameters
pageIndex int
scale double
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task<Avalonia.Media.Imaging.Bitmap>
ResetZoom Method
Resets zoom to 100%.
public void ResetZoom()
Save Method
Saves the document in place (fire-and-forget); a failure, including a stream-backed document with no path, is reported through Avalonia.Controls.PdfViewer.ErrorMessage. See Avalonia.Controls.PdfViewer.SaveAsync.
public void Save()
SaveAs Method
Saves via the save picker (fire-and-forget). See Avalonia.Controls.PdfViewer.SaveAsAsync(System.Threading.CancellationToken).
public void SaveAs()
SaveAsAsync Method
Writes the document, with its annotation edits, to a file chosen by the user. Raises Avalonia.Controls.PdfViewer.SaveAsRequested first; when the host does not handle it, the platform save picker of the owning Avalonia.Controls.TopLevel is used. Choosing the open file saves in place (see Avalonia.Controls.PdfViewer.SaveAsync); choosing another local path writes it and the viewer switches to that file, keeping the current page.
public System.Threading.Tasks.Task SaveAsAsync(System.Threading.CancellationToken cancellationToken)
Parameters
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task
Exceptions
SaveAsync Method
Saves the document in place to its original Avalonia.Controls.PdfViewer.Source path, including any
annotation edits. No-op when Avalonia.Controls.PdfViewer.AllowDocumentSaving is false or when no
document is loaded. A document loaded from a stream or byte array has no path to save to:
use Avalonia.Controls.PdfViewer.SaveDocumentAsync(System.IO.Stream) or Avalonia.Controls.PdfViewer.SaveAsAsync(System.Threading.CancellationToken) for those.
public System.Threading.Tasks.Task SaveAsync()
Returns
System.Threading.Tasks.Task
Exceptions
SaveDocumentAsync overloads
SaveDocumentAsync Method
Saves the document (with all annotations) to a stream.
public System.Threading.Tasks.Task SaveDocumentAsync(System.IO.Stream stream)
Parameters
stream System.IO.Stream
Returns
System.Threading.Tasks.Task
SaveDocumentAsync Method
Saves the document (with all annotations) to a file path.
public System.Threading.Tasks.Task SaveDocumentAsync(string filePath)
Parameters
filePath string
Returns
System.Threading.Tasks.Task
SearchAsync overloads
SearchAsync Method
Searches for text in the document and publishes the results (Avalonia.Controls.PdfViewer.SearchResults, find next/previous, Avalonia.Controls.PdfViewer.SearchCompleted). A failure is reported through Avalonia.Controls.PdfViewer.ErrorMessage and returns an empty list.
public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Pdf.Core.PdfSearchResult>> SearchAsync(string query, Avalonia.Controls.Pdf.Core.SearchOptions options)
Parameters
query string
options Avalonia.Controls.Pdf.Core.SearchOptions
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Pdf.Core.PdfSearchResult>>
SearchAsync Method
Searches for text in the document and publishes the results. The document is scanned a
page at a time, so cancellationToken stops the search within a page.
public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Pdf.Core.PdfSearchResult>> SearchAsync(string query, Avalonia.Controls.Pdf.Core.SearchOptions options, System.Threading.CancellationToken cancellationToken)
Parameters
query string
options Avalonia.Controls.Pdf.Core.SearchOptions
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Pdf.Core.PdfSearchResult>>
Exceptions
SelectAll Method
Selects all text on the current page.
public void SelectAll()
Share Method
Shares the current document (fire-and-forget). Errors surface via Avalonia.Controls.PdfViewer.ErrorMessage.
public void Share()
ShareAsync Method
Shares the current document. Raises Avalonia.Controls.PdfViewer.ShareRequested first; if the handler marks it handled nothing else happens, otherwise the Avalonia.Controls.PdfViewer.ShareService shows the system share sheet. No-op when no document is loaded.
public System.Threading.Tasks.Task ShareAsync(Avalonia.Controls.Pdf.Services.ShareOptions options, System.Threading.CancellationToken cancellationToken)
Parameters
options Avalonia.Controls.Pdf.Services.ShareOptions
cancellationToken System.Threading.CancellationToken
Returns
System.Threading.Tasks.Task
Exceptions
SquigglySelectionAsync Method
public System.Threading.Tasks.Task<int> SquigglySelectionAsync(Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor> color)
Parameters
color Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor>
Returns
System.Threading.Tasks.Task<int>
StampNameForLabel Method
Stamp name for a label: the label without spaces, so standard labels map to standard names.
public string StampNameForLabel(string label)
Parameters
label string
Returns
string
StampStyleDisplayName Method
The English name of a style as shown in the Stamp dropdown (see Avalonia.Controls.PdfViewer.Strings for other languages).
public string StampStyleDisplayName(Avalonia.Controls.PdfStampStyle style)
Parameters
style Avalonia.Controls.PdfStampStyle
Returns
string
StrikeoutSelectionAsync Method
public System.Threading.Tasks.Task<int> StrikeoutSelectionAsync(Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor> color)
Parameters
color Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor>
Returns
System.Threading.Tasks.Task<int>
ToggleBookmark Method
Toggles the bookmark for the given 1-based page. Returns the new state ( when the page is now bookmarked).
public bool ToggleBookmark(int pageNumber)
Parameters
pageNumber int
Returns
bool
ToggleBookmarkCurrentPage Method
Toggles the bookmark for the current page (the ⌘D / Ctrl+D action).
public void ToggleBookmarkCurrentPage()
UnderlineSelectionAsync Method
public System.Threading.Tasks.Task<int> UnderlineSelectionAsync(Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor> color)
Parameters
color Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor>
Returns
System.Threading.Tasks.Task<int>
Undo Method
Reverts the most recent edit, if any.
public void Undo()
UndoAsync Method
Reverts the most recent edit and completes when the document has been updated.
public System.Threading.Tasks.Task UndoAsync()
Returns
System.Threading.Tasks.Task
UpdateStickyNoteAsync Method
public System.Threading.Tasks.Task UpdateStickyNoteAsync(int pageIndex, int annotIndex, string text, Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor> color)
Parameters
pageIndex int
annotIndex int
text string
color Nullable<Avalonia.Controls.Pdf.Core.PdfAnnotationColor>
Returns
System.Threading.Tasks.Task
ZoomIn Method
Zooms in to the next preset level.
public void ZoomIn()
ZoomOut Method
Zooms out to the previous preset level.
public void ZoomOut()
Properties
| Name | Description |
|---|---|
| ActiveTool | Gets or sets the tool applied to the next pointer gesture on a page. The built-in toolbar and a host's own controls both read and write this one value: setting it arms the tool (and, for Avalonia.Controls.PdfViewerTool.Shape, keeps or defaults Avalonia.Controls.PdfViewer.SelectedShapeType), Avalonia.Controls.PdfViewerTool.None disarms every tool. Editing capability still applies: while Avalonia.Controls.PdfViewer.CanEditAnnotations is false the value stays Avalonia.Controls.PdfViewerTool.None. |
| ActualThemeVariant | Gets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. Inherited from StyledElement. |
| AddBookmarkCommand | Gets a command that bookmarks the page supplied as the command parameter (defaulting to the current page). Enabled while a document is loaded. |
| AllowAnnotationEditing | Gets or sets whether annotation tools may be used. Default true. Ignored (treated as false) when Avalonia.Controls.PdfViewer.IsReadOnly is set. |
| AllowDocumentSaving | Gets or sets whether the built-in save command/UI is available. Default true. Programmatic Avalonia.Controls.PdfViewer.SaveDocumentAsync(System.IO.Stream) is unaffected. |
| AllowFormEditing | Gets or sets whether interactive form fields accept input. Default true. Ignored (treated as false) when Avalonia.Controls.PdfViewer.IsReadOnly is set. |
| AllowTextSelection | Gets or sets whether the user can select (and copy) text. Default true. |
| AnnotationMode | Gets or sets the annotation interaction mode. |
| AutoSave | Gets or sets whether the document is automatically saved after annotation changes. Requires Avalonia.Controls.PdfViewer.Source to be set (file-path based loading). |
| Background | Gets or sets the brush used to draw the control's background. Inherited from TemplatedControl. |
| BackgroundSizing | Gets or sets how the control's background is drawn relative to the control's border. Inherited from TemplatedControl. |
| Bookmarks | Gets the current user bookmarks, ordered by page. These are saved reading positions, distinct from the document outline (Avalonia.Controls.PdfViewer.HasOutline). Persisted to the document's XMP metadata in the Preview-compatible apple-preview format. |
| BorderBrush | Gets or sets the brush used to draw the control's border. Inherited from TemplatedControl. |
| BorderThickness | Gets or sets the thickness of the control's border. Inherited from TemplatedControl. |
| Bounds | Gets the bounds of the control relative to its parent. Inherited from Visual. |
| CacheMode | Gets or sets the cache mode of the visual. Inherited from Visual. |
| CanEditAnnotations | Gets whether annotation editing is currently permitted — when Avalonia.Controls.PdfViewer.IsReadOnly is set or Avalonia.Controls.PdfViewer.AllowAnnotationEditing is cleared. Bindable so the template can gate the annotation toolbar. |
| CanPrint | True when a document is loaded and printing can go somewhere: either Avalonia.Controls.PdfViewer.PrintRequested has a handler or a supported Avalonia.Controls.PdfViewer.PrintService exists. |
| CanRedo | Gets whether there is an undone edit that Avalonia.Controls.PdfViewer.Redo can re-apply. |
| CanShare | True when a document is loaded and sharing can go somewhere: either Avalonia.Controls.PdfViewer.ShareRequested has a handler or a supported Avalonia.Controls.PdfViewer.ShareService exists. |
| CanUndo | Gets whether there is an edit that Avalonia.Controls.PdfViewer.Undo can revert. Bindable so a host or template can enable an Undo button. |
| Classes | Gets or sets the styled element's classes. Inherited from StyledElement. |
| Clip | Gets or sets the geometry clip for this visual. Inherited from Visual. |
| ClipToBounds | Gets or sets a value indicating whether the control should be clipped to its bounds. Inherited from Visual. |
| ContextFlyout | Gets or sets a context flyout to the control Inherited from Control. |
| ContextMenu | Gets or sets a context menu to the control. Inherited from Control. |
| CopyCommand | Gets a command that copies the current text selection to the clipboard. |
| CornerRadius | Gets or sets the radius of the border rounded corners. Inherited from TemplatedControl. |
| CurrentPage | Gets or sets the current page number (1-based). |
| CurrentSearchResultIndex | Gets the 0-based index of the active search match, or -1 when there are none. |
| Cursor | Gets or sets associated mouse cursor. Inherited from InputElement. |
| DataContext | Gets or sets the control's data context. Inherited from StyledElement. |
| DataTemplates | Gets or sets the data templates for the control. Inherited from Control. |
| DesiredSize | Gets the size that this element computed during the measure pass of the layout process. Inherited from Layoutable. |
| DismissErrorCommand | Gets a command that clears Avalonia.Controls.PdfViewer.ErrorMessage. Enabled while an error is shown. |
| Dispatcher | Returns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject. |
| DocumentSource | Gets or sets the document to display, accepting a string file path, a Uri (file scheme), a System.IO.Stream, or a byte array. This is the binding-friendly alternative to Avalonia.Controls.PdfViewer.Source; assigning it loads the document immediately. Setting it to null closes the current document. |
| DrawStrokeColor | Gets or sets the default draw/ink stroke color. |
| DrawStrokeWidth | Gets or sets the draw stroke width in PDF points (0.5–20). |
| Effect | Gets or sets the effect of the control. Inherited from Visual. |
| EnableKeyboardShortcuts | Gets or sets whether the viewer handles its built-in keyboard shortcuts — copy, select-all, the zoom accelerators, save, arrow-key navigation and nudging. Default true. Set false when a host binds those keystrokes to its own commands and doesn't want the viewer to consume them. Form-field text input and Escape-to-deselect are unaffected. |
| ErrorMessage | Gets the current error message, if any. |
| FitPageCommand | Gets a command that fits the whole page to the viewport. |
| FitWidthCommand | Gets a command that fits the page width to the viewport. |
| FlowDirection | Gets or sets the text flow direction. Inherited from Visual. |
| Focusable | Gets or sets a value indicating whether the control can receive focus. Inherited from InputElement. |
| FocusAdorner | Gets or sets the control's focus adorner. Inherited from Control. |
| FontFamily | Gets or sets the font family used to draw the control's text. Inherited from TemplatedControl. |
| FontFeatures | Gets or sets the font features turned on/off. Inherited from TemplatedControl. |
| FontSize | Gets or sets the size of the control's text in points. Inherited from TemplatedControl. |
| FontStretch | Gets or sets the font stretch used to draw the control's text. Inherited from TemplatedControl. |
| FontStyle | Gets or sets the font style used to draw the control's text. Inherited from TemplatedControl. |
| FontWeight | Gets or sets the font weight used to draw the control's text. Inherited from TemplatedControl. |
| Foreground | Gets or sets the brush used to draw the control's text and other foreground elements. Inherited from TemplatedControl. |
| GestureRecognizers | Inherited from InputElement. |
| GoToPageCommand | Gets a command that navigates to the page number supplied as the command parameter (an int or a string parseable as one). |
| HasBookmarks | Gets whether the document has bookmarks. |
| HasDocument | Gets whether a document is currently open. The template uses it to show errors as a dismissible banner over an open document instead of the full-canvas error state. |
| HasMirrorTransform | Gets or sets a value indicating whether to apply mirror transform on this control. Inherited from Visual. |
| HasOutline | Gets whether the document has an outline (table of contents). |
| HasSelection | Gets whether there is an active text selection. |
| Height | Gets or sets the height of the element. Inherited from Layoutable. |
| HighlightColor | Gets or sets the default highlight annotation color. |
| HorizontalAlignment | Gets or sets the element's preferred horizontal alignment in its parent. Inherited from Layoutable. |
| IncludeStampDate | Gets or sets whether stamps added from now on carry the current date as a second line (see Avalonia.Controls.PdfViewer.StampDateFormat). The Stamp dropdown's "Include date" toggle sets this too. Default . Existing stamps keep their date, or their lack of one. |
| IsArrangeValid | Gets a value indicating whether the control's layouts arrange is valid. Inherited from Layoutable. |
| IsArrowKeyNudgeEnabled | Gets or sets whether the arrow keys move the selected annotation by one pixel (ten with Shift) instead of navigating. Default true. With no annotation selected the arrow keys always navigate. Also off when Avalonia.Controls.PdfViewer.EnableKeyboardShortcuts is false. |
| IsBookmarksEnabled | Gets or sets whether the Bookmarks sidebar pane is available. When its tab is hidden and the mode can't be selected. Default . |
| IsDirty | Gets whether the document has edits (annotations, form values, redactions, bookmarks) that have not been written since it was loaded or last saved. Cleared by a successful Avalonia.Controls.PdfViewer.SaveAsync, Avalonia.Controls.PdfViewer.SaveDocumentAsync(System.IO.Stream) or auto-save and by loading another document. Undoing back to the saved state does not clear it. |
| IsDrawToolVisible | Gets or sets whether the Draw (ink) tool is shown. Default . |
| IsEffectivelyEnabled | Gets a value indicating whether this control and all its parents are enabled. Inherited from InputElement. |
| IsEffectivelyVisible | Gets a value indicating whether this control and all its parents are visible. Inherited from Visual. |
| IsEnabled | Gets or sets a value indicating whether the control is enabled for user interaction. Inherited from InputElement. |
| IsFocused | Gets a value indicating whether the control is focused. Inherited from InputElement. |
| IsHighlightToolVisible | Gets or sets whether the Highlight tool is shown. Default . |
| IsHitTestVisible | Gets or sets a value indicating whether the control is considered for hit testing. Inherited from InputElement. |
| IsInitialized | Gets a value that indicates whether the element has finished initialization. Inherited from StyledElement. |
| IsKeyboardFocusWithin | Gets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements. Inherited from InputElement. |
| IsLinkToolVisible | Gets or sets whether the Link tool is shown. Default . |
| IsLoaded | Gets a value indicating whether the control is fully constructed in the visual tree and both layout and render are complete. Inherited from Control. |
| IsLoading | Gets whether the control is currently loading a document. |
| IsMeasureValid | Gets a value indicating whether the control's layout measure is valid. Inherited from Layoutable. |
| IsMobileLayout | Gets whether the touch-optimised mobile layout is used. When true, the annotation tools are relocated from the centre of the top toolbar to a dedicated bar along the bottom of the control; the search field, page navigation and menu stay in the top toolbar. The control manages this automatically — true on iOS/Android, or on any platform when the control is narrower than 500 device-independent pixels — recomputing as it resizes, so any value set externally is transient. |
| IsMoreOptionsVisible | Gets or sets whether the toolbar's More Options menu (print, share, view modes) is shown. |
| IsNoteToolVisible | Gets or sets whether the Note (sticky note) tool is shown. Default . |
| IsOpenVisible | Gets or sets whether an Open entry is offered at the top of the More Options menu. Off by default: most hosts load documents themselves. The entry runs Avalonia.Controls.PdfViewer.OpenAsync(System.Threading.CancellationToken). |
| IsPointerOver | Gets a value indicating whether the pointer is currently over the control. Inherited from InputElement. |
| IsPrintVisible | Gets or sets whether the Print entry is offered in the More Options menu. Even when true the entry is hidden on platforms without a print service unless Avalonia.Controls.PdfViewer.PrintRequested is handled. |
| IsReadOnly | Gets or sets a value that, when true, disables all document editing (annotation tools and form input). Text selection and navigation remain available. |
| IsRedactionUndoEnabled | Gets or sets whether redactions are recorded in the undo history. When false a redaction is final as soon as it is applied and holds no document copy; other edits stay undoable. Defaults to true. |
| IsRedactToolVisible | Gets or sets whether the Redact tool is shown. Default . |
| IsSaveAsVisible | Gets or sets whether a Save As entry is offered in the More Options menu. Off by default. The entry runs Avalonia.Controls.PdfViewer.SaveAsAsync(System.Threading.CancellationToken). |
| IsSaveVisible | Gets or sets whether a Save entry (save in place, see Avalonia.Controls.PdfViewer.SaveAsync) is offered in the More Options menu. Off by default; hidden anyway while Avalonia.Controls.PdfViewer.AllowDocumentSaving is false. |
| IsShapeToolVisible | Gets or sets whether the Shapes tool is shown. Default . |
| IsShareVisible | Gets or sets whether the Share entry is offered in the More Options menu. Even when true the entry is hidden on platforms without a share service unless Avalonia.Controls.PdfViewer.ShareRequested is handled. |
| IsSidebarOpen | Gets whether the sidebar is open (any mode other than None). |
| IsSidebarVisible | Gets or sets whether the sidebar is visible (including collapsed state). When false, the sidebar is completely hidden and cannot be toggled. |
| IsSquigglyToolVisible | Gets or sets whether the Squiggly tool is shown. Default . |
| IsStampToolVisible | Gets or sets whether the Stamp dropdown is shown in the toolbar. Default . |
| IsStrikethroughToolVisible | Gets or sets whether the Strikethrough tool is shown. Default . |
| IsTableOfContentsEnabled | Gets or sets whether the Table of Contents sidebar pane is available. When its tab is hidden and the mode can't be selected. Default . |
| IsTabStop | Gets or sets a value that indicates whether the control is included in tab navigation. Inherited from InputElement. |
| IsTextToolVisible | Gets or sets whether the Add Text (free text) tool is shown. Default . |
| IsToolbarVisible | Gets or sets whether the toolbar is visible. |
| IsUnderlineToolVisible | Gets or sets whether the Underline tool is shown. Default . |
| IsVisible | Gets or sets a value indicating whether this control is visible. Inherited from Visual. |
| Item | Inherited from AvaloniaObject. |
| KeyBindings | Inherited from InputElement. |
| LetterSpacing | Gets or sets the letter spacing for the control's text content. Inherited from TemplatedControl. |
| Margin | Gets or sets the margin around the element. Inherited from Layoutable. |
| MaxHeight | Gets or sets the maximum height of the element. Inherited from Layoutable. |
| MaxRedactionUndoSteps | Gets or sets how many redactions can be undone (0–100). A redaction rewrites page content, so each undo step keeps a serialized copy of the whole document as it was; this limit bounds that memory separately from Avalonia.Controls.PdfViewer.MaxUndoSteps. The most recent redactions are kept: when the limit is exceeded the oldest redaction step is dropped from the history while the annotation steps around it stay. Zero records no redactions. Defaults to 10. |
| MaxRenderScale | Gets or sets the maximum device-pixel ratio the page raster is rendered at. Pages are rendered at ZoomLevel × clamp(screenScaling, 1, MaxRenderScale) pixels so text stays crisp on HiDPI displays. Higher values are sharper but use more memory (bitmap bytes scale with the square of the ratio); set to 1.0 to disable DPI-aware rendering. Default 2.0. |
| MaxUndoSteps | Gets or sets how many undo steps are retained (0–1000). Lowering it trims the oldest history. Zero disables undo/redo entirely. Defaults to 100. |
| MaxWidth | Gets or sets the maximum width of the element. Inherited from Layoutable. |
| MaxZoom | Gets or sets the maximum allowed Avalonia.Controls.PdfViewer.ZoomLevel (1.0 == 100%). Default 5.0, at most Avalonia.Controls.PdfViewer.MaxZoomLimit. |
| Metadata | Gets the loaded document's metadata, or null when no document is open. |
| MinHeight | Gets or sets the minimum height of the element. Inherited from Layoutable. |
| MinWidth | Gets or sets the minimum width of the element. Inherited from Layoutable. |
| MinZoom | Gets or sets the minimum allowed Avalonia.Controls.PdfViewer.ZoomLevel (1.0 == 100%). Default 0.05. |
| Name | Gets or sets the name of the styled element. Inherited from StyledElement. |
| NextPageCommand | Gets a command that advances to the next page. Disabled on the last page. |
| NoteColor | Gets or sets the default note color. |
| Opacity | Gets or sets the opacity of the control. Inherited from Visual. |
| OpacityMask | Gets or sets the opacity mask of the control. Inherited from Visual. |
| OpenCommand | Gets a command that opens a document via Avalonia.Controls.PdfViewer.Open (file picker or Avalonia.Controls.PdfViewer.OpenRequested). |
| Padding | Gets or sets the padding placed between the border of the control and its content. Inherited from TemplatedControl. |
| PageCount | Gets the total number of pages in the document. |
| PageRenderBuffer | Gets or sets how many pages on each side of the viewport are decoded ahead of time in continuous mode. Higher values reduce blank placeholders while scrolling at the cost of memory; lower values minimize memory. Clamped to [0, Avalonia.Controls.PdfViewer.MaxPageRenderBuffer]. Default is 2. |
| PageRetentionBuffer | Gets or sets how many pages on each side of the viewport are kept decoded before being evicted in continuous mode. Acts as hysteresis: pages between the render buffer and this margin stay in memory so short back-and-forth scrolling does not re-render them. If set below Avalonia.Controls.PdfViewer.PageRenderBuffer, the render buffer is used for retention. Clamped to [0, Avalonia.Controls.PdfViewer.MaxPageRetentionBuffer]. Default is 4. |
| Parent | Gets the styled element's logical parent. Inherited from StyledElement. |
| Password | Gets or sets the password for encrypted PDFs. |
| Permissions | Gets the loaded document's permission flags, or null when no document is open. |
| PreviousPageCommand | Gets a command that goes to the previous page. Disabled on the first page. |
| PrintCommand | Gets a command that prints the document via the configured Avalonia.Controls.PdfViewer.PrintService. Disabled when no print service is set. |
| PrintService | Gets or sets the print service used by Avalonia.Controls.PdfViewer.Print, Avalonia.Controls.PdfViewer.PrintAsync(Avalonia.Controls.Pdf.Services.PrintOptions,System.Threading.CancellationToken) and Avalonia.Controls.PdfViewer.PrintCommand. While the property is unset it resolves to the built-in service for the current platform (Windows, macOS, iOS, Android; null elsewhere). Assign or bind your own implementation to replace it, set null to disable the built-in one, or clear the property to return to the platform default. Handle Avalonia.Controls.PdfViewer.PrintRequested to bypass the service entirely. |
| RedactionRemovesHiddenInformation | Gets or sets whether a redaction also removes the places a document keeps copies of its content outside the page: the tagged structure tree (with its /ActualText and /Alt text), the redacted page's embedded thumbnail, and the XMP and Info metadata (title, author, keywords). Default true. Objects nothing references any more are dropped either way. Outline titles and file attachments are never touched. |
| RemoveBookmarkCommand | Gets a command that removes the bookmark for the page supplied as the command parameter (defaulting to the current page). Enabled while a document is loaded. |
| RenderTransform | Gets or sets the render transform of the control. Inherited from Visual. |
| RenderTransformOrigin | Gets or sets the transform origin of the control. Inherited from Visual. |
| ResetZoomCommand | Gets a command that resets the zoom to 100%. Enabled while a document is loaded. |
| Resources | Gets or sets the styled element's resource dictionary. Inherited from StyledElement. |
| RespectDocumentPermissions | Gets or sets whether the document's own permission flags (Avalonia.Controls.PdfViewer.Permissions, the encryption dictionary's /P entry) restrict what the viewer offers: annotation editing, form filling, text selection and printing are each withheld when the document forbids them. Default true. A document opened with its owner password is unrestricted. Set false to ignore the flags, as an owner's own tooling might. |
| SaveAsCommand | Gets a command that saves to a chosen file via Avalonia.Controls.PdfViewer.SaveAs. |
| SaveCommand | Gets a command that saves the document in place. Honors Avalonia.Controls.PdfViewer.AllowDocumentSaving. |
| SearchMatchCase | Gets or sets whether the toolbar search matches letter case. Default false. |
| SearchMatchWholeWord | Gets or sets whether the toolbar search matches whole words only. Default false. |
| SearchQuery | Gets or sets the search query. |
| SearchResultCount | Gets the number of matches for the current search. |
| SearchResults | Gets the current search results. |
| SelectAllCommand | Gets a command that selects all text on the current page. |
| SelectedShapeType | Gets or sets the active shape tool type. |
| SelectedText | Gets the currently selected text. |
| SetToolCommand | Gets a command that activates a tool: the parameter is a Avalonia.Controls.PdfViewerTool (or its name). Lets a host with its own toolbar drive the same tools as the built-in one. |
| ShapeFillColor | Gets or sets the default shape fill color. Null means no fill. |
| ShapeStrokeColor | Gets or sets the default shape stroke color. Null means no stroke. |
| ShapeStrokeWidth | Gets or sets the default shape stroke width in PDF points (0.5–20). |
| ShapeSubtypeMode | Gets or sets how shapes are written to the file: with their standard subtypes so other readers can edit them, or as stamps that survive other editors untouched. See Avalonia.Controls.PdfShapeSubtypeMode. Default Avalonia.Controls.PdfShapeSubtypeMode.Auto. |
| ShareCommand | Gets a command that shares the document via the configured Avalonia.Controls.PdfViewer.ShareService or a Avalonia.Controls.PdfViewer.ShareRequested handler. Disabled when neither is available. |
| ShareService | Gets or sets the share service used by Avalonia.Controls.PdfViewer.Share, Avalonia.Controls.PdfViewer.ShareAsync(Avalonia.Controls.Pdf.Services.ShareOptions,System.Threading.CancellationToken) and Avalonia.Controls.PdfViewer.ShareCommand. Same semantics as Avalonia.Controls.PdfViewer.PrintService: unset resolves to the platform service, null disables it, clearing the property restores the default. |
| ShowBookmarkIndicators | Gets or sets whether a bookmark ribbon is drawn in the top-right corner of bookmarked pages. Defaults to . |
| SidebarMode | Gets or sets the sidebar mode. |
| SidebarPlacement | Gets or sets how the sidebar sits relative to the document. Avalonia.Controls.SidebarPlacement.Auto (default) mirrors the toolbar layout — overlay on mobile, offset on desktop; Avalonia.Controls.SidebarPlacement.Overlay floats it over a centered document; Avalonia.Controls.SidebarPlacement.Offset shifts the document canvas right by the sidebar width so they don't overlap. |
| SidebarSelectionBrush | Optional override for the selection colour used across all sidebar panes — table of contents, bookmarks, and the selected thumbnail. When set it replaces the theme's selection accent; when the theme default applies (accent-aware in Fluent, monotone in the Default theme). The contrasting foreground (text/chevron) is chosen automatically from the brush's luminance. |
| SidebarWidth | Gets or sets the sidebar width in DIPs (100–300). |
| Source | Gets or sets the path to the PDF file to display. |
| SquigglyColor | Gets or sets the default squiggly underline annotation color. |
| StampColor | Gets or sets the colour used for every stamp. Null (the default) picks a colour by meaning: green for approvals and completions, blue for informational stamps, red for restrictions. |
| StampDateFormat | Gets or sets the .NET date format of a stamp's date line, formatted with the invariant culture and drawn in capitals. Default Avalonia.Controls.PdfViewer.DefaultStampDateFormat ("12 SEP 2026"). |
| StampDateText | The date line a stamp placed now would carry: today in Avalonia.Controls.PdfViewer.StampDateFormat, in capitals. |
| StampLabels | Gets or sets the labels listed by the Stamp dropdown. A label is drawn in capitals and stored as the stamp's /Name with spaces removed ("Not Approved" becomes /NotApproved, one of the standard names). Default Avalonia.Controls.PdfViewer.DefaultStampLabels. |
| StampStyle | Gets or sets the look of stamps added from now on. See Avalonia.Controls.PdfStampStyle. Default Avalonia.Controls.PdfStampStyle.Classic. The Stamp dropdown's style selector sets this too. Existing stamps keep their own style. |
| StrikeoutColor | Gets or sets the default strikeout annotation color. |
| Strings | Gets or sets the user-facing texts of the viewer (tooltips, menus, dialogs, sidebar labels, placeholders, error banners). The template binds to it, so the toolbar follows a change at once; texts built in code (context menus, the Stamp dropdown, thumbnail labels) use the current value when they are next built. Set it before loading a document for a complete switch. Never null: assigning null restores Avalonia.Controls.PdfViewerStrings.Default. |
| StyleKey | Gets the type by which the element is styled. Inherited from StyledElement. |
| Styles | Gets the styles for the styled element. Inherited from StyledElement. |
| TabIndex | Gets or sets a value that determines the order in which elements receive focus when the user navigates through controls by pressing the Tab key. Inherited from InputElement. |
| Tag | Gets or sets a user-defined object attached to the control. Inherited from Control. |
| Template | Gets or sets the template that defines the control's appearance. Inherited from TemplatedControl. |
| TemplatedParent | Gets the styled element whose lookless template this styled element is part of. Inherited from StyledElement. |
| TextAnnotationFillColor | Gets or sets the text annotation fill color. Null means no fill. |
| TextAnnotationFont | Gets or sets the text annotation font name. |
| TextAnnotationFontAttributes | Gets or sets the text annotation font attributes. |
| TextAnnotationFontSize | Gets or sets the text annotation font size (1–144). |
| TextAnnotationStrokeColor | Gets or sets the text annotation stroke color. Null means no stroke. |
| TextAnnotationStrokeWidth | Gets or sets the text annotation stroke width (0.5–20). |
| TextAnnotationTextAlign | Gets or sets the text annotation text alignment. |
| TextAnnotationTextColor | Gets or sets the text annotation text color. |
| Theme | Gets or sets the theme to be applied to the element. Inherited from StyledElement. |
| ToggleBookmarkCommand | Gets a command that toggles the bookmark for the page supplied as the command parameter (an int or a string parseable as one), or the current page when no parameter is given. Mirrors the ⌘D / Ctrl+D shortcut. |
| ToolbarLayoutMode | Gets or sets how the toolbar layout is chosen. Avalonia.Controls.PdfToolbarLayoutMode.Mobile or Avalonia.Controls.PdfToolbarLayoutMode.Desktop force that layout regardless of platform or width; Avalonia.Controls.PdfToolbarLayoutMode.Auto (default) decides from platform and available width. This is the supported way to force the touch toolbar; Avalonia.Controls.PdfViewer.IsMobileLayout is the resulting effective state. |
| Transitions | Gets or sets the property transitions for the control. Inherited from Animatable. |
| UnderlineColor | Gets or sets the default underline annotation color. |
| UseLayoutRounding | Gets or sets a value that determines whether the element should be snapped to pixel boundaries at layout time. Inherited from Layoutable. |
| VerticalAlignment | Gets or sets the element's preferred vertical alignment in its parent. Inherited from Layoutable. |
| VerticalScrollOffset | Gets or sets the vertical scroll offset of the page area, in device-independent pixels. |
| ViewMode | Gets or sets the view mode. |
| Width | Gets or sets the width of the element. Inherited from Layoutable. |
| ZIndex | Gets or sets the Z index of the control. Inherited from Visual. |
| ZoomInCommand | Gets a command that zooms in one step. Enabled while a document is loaded. |
| ZoomLevel | Gets or sets the zoom level (1.0 = 100%). |
| ZoomMode | Gets or sets how pages are sized to the viewport. Fit modes recalculate Avalonia.Controls.PdfViewer.ZoomLevel on resize; Avalonia.Controls.PdfZoomMode.Manual leaves it fixed. |
| ZoomOutCommand | Gets a command that zooms out one step. Enabled while a document is loaded. |
| ZoomStep | Gets or sets the additive increment used by Avalonia.Controls.PdfViewer.ZoomIn / Avalonia.Controls.PdfViewer.ZoomOut. When 0 (the default), the built-in preset levels are used instead. |
ActiveTool Property
Gets or sets the tool applied to the next pointer gesture on a page. The built-in toolbar and a host's own controls both read and write this one value: setting it arms the tool (and, for Avalonia.Controls.PdfViewerTool.Shape, keeps or defaults Avalonia.Controls.PdfViewer.SelectedShapeType), Avalonia.Controls.PdfViewerTool.None disarms every tool. Editing capability still applies: while Avalonia.Controls.PdfViewer.CanEditAnnotations is false the value stays Avalonia.Controls.PdfViewerTool.None.
public Avalonia.Controls.PdfViewerTool ActiveTool { get; set; }
AddBookmarkCommand Property
Gets a command that bookmarks the page supplied as the command parameter (defaulting to the current page). Enabled while a document is loaded.
public System.Windows.Input.ICommand AddBookmarkCommand { get; set; }
AllowAnnotationEditing Property
Gets or sets whether annotation tools may be used. Default true.
Ignored (treated as false) when Avalonia.Controls.PdfViewer.IsReadOnly is set.
public bool AllowAnnotationEditing { get; set; }
AllowDocumentSaving Property
Gets or sets whether the built-in save command/UI is available. Default true.
Programmatic Avalonia.Controls.PdfViewer.SaveDocumentAsync(System.IO.Stream) is unaffected.
public bool AllowDocumentSaving { get; set; }
AllowFormEditing Property
Gets or sets whether interactive form fields accept input. Default true.
Ignored (treated as false) when Avalonia.Controls.PdfViewer.IsReadOnly is set.
public bool AllowFormEditing { get; set; }
AllowTextSelection Property
Gets or sets whether the user can select (and copy) text. Default true.
public bool AllowTextSelection { get; set; }
AnnotationMode Property
Gets or sets the annotation interaction mode.
public Avalonia.Controls.AnnotationMode AnnotationMode { get; set; }
AutoSave Property
Gets or sets whether the document is automatically saved after annotation changes. Requires Avalonia.Controls.PdfViewer.Source to be set (file-path based loading).
public bool AutoSave { get; set; }
Bookmarks Property
Gets the current user bookmarks, ordered by page. These are saved reading positions,
distinct from the document outline (Avalonia.Controls.PdfViewer.HasOutline). Persisted to the document's
XMP metadata in the Preview-compatible apple-preview format.
public System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Pdf.Core.PdfUserBookmark> Bookmarks { get; set; }
CanEditAnnotations Property
Gets whether annotation editing is currently permitted — when Avalonia.Controls.PdfViewer.IsReadOnly is set or Avalonia.Controls.PdfViewer.AllowAnnotationEditing is cleared. Bindable so the template can gate the annotation toolbar.
public bool CanEditAnnotations { get; set; }
CanPrint Property
True when a document is loaded and printing can go somewhere: either Avalonia.Controls.PdfViewer.PrintRequested has a handler or a supported Avalonia.Controls.PdfViewer.PrintService exists.
public bool CanPrint { get; set; }
CanRedo Property
Gets whether there is an undone edit that Avalonia.Controls.PdfViewer.Redo can re-apply.
public bool CanRedo { get; set; }
CanShare Property
True when a document is loaded and sharing can go somewhere: either Avalonia.Controls.PdfViewer.ShareRequested has a handler or a supported Avalonia.Controls.PdfViewer.ShareService exists.
public bool CanShare { get; set; }
CanUndo Property
Gets whether there is an edit that Avalonia.Controls.PdfViewer.Undo can revert. Bindable so a host or template can enable an Undo button.
public bool CanUndo { get; set; }
CopyCommand Property
Gets a command that copies the current text selection to the clipboard.
public System.Windows.Input.ICommand CopyCommand { get; set; }
CurrentPage Property
Gets or sets the current page number (1-based).
public int CurrentPage { get; set; }
CurrentSearchResultIndex Property
Gets the 0-based index of the active search match, or -1 when there are none.
public int CurrentSearchResultIndex { get; set; }
DismissErrorCommand Property
Gets a command that clears Avalonia.Controls.PdfViewer.ErrorMessage. Enabled while an error is shown.
public System.Windows.Input.ICommand DismissErrorCommand { get; set; }
DocumentSource Property
Gets or sets the document to display, accepting a string file path,
a Uri (file scheme), a System.IO.Stream, or a byte array.
This is the binding-friendly alternative to Avalonia.Controls.PdfViewer.Source; assigning it loads
the document immediately. Setting it to null closes the current document.
public object DocumentSource { get; set; }
DrawStrokeColor Property
Gets or sets the default draw/ink stroke color.
public Avalonia.Controls.Pdf.Core.PdfAnnotationColor DrawStrokeColor { get; set; }
DrawStrokeWidth Property
Gets or sets the draw stroke width in PDF points (0.5–20).
public float DrawStrokeWidth { get; set; }
EnableKeyboardShortcuts Property
Gets or sets whether the viewer handles its built-in keyboard shortcuts — copy, select-all,
the zoom accelerators, save, arrow-key navigation and nudging. Default true. Set false when a
host binds those keystrokes to its own commands and doesn't want the viewer to consume them.
Form-field text input and Escape-to-deselect are unaffected.
public bool EnableKeyboardShortcuts { get; set; }
ErrorMessage Property
Gets the current error message, if any.
public string ErrorMessage { get; set; }
FitPageCommand Property
Gets a command that fits the whole page to the viewport.
public System.Windows.Input.ICommand FitPageCommand { get; set; }
FitWidthCommand Property
Gets a command that fits the page width to the viewport.
public System.Windows.Input.ICommand FitWidthCommand { get; set; }
GoToPageCommand Property
Gets a command that navigates to the page number supplied as the command parameter (an int or a string parseable as one).
public System.Windows.Input.ICommand GoToPageCommand { get; set; }
HasBookmarks Property
Gets whether the document has bookmarks.
public bool HasBookmarks { get; set; }
HasDocument Property
Gets whether a document is currently open. The template uses it to show errors as a dismissible banner over an open document instead of the full-canvas error state.
public bool HasDocument { get; set; }
HasOutline Property
Gets whether the document has an outline (table of contents).
public bool HasOutline { get; set; }
HasSelection Property
Gets whether there is an active text selection.
public bool HasSelection { get; set; }
HighlightColor Property
Gets or sets the default highlight annotation color.
public Avalonia.Controls.Pdf.Core.PdfAnnotationColor HighlightColor { get; set; }
IncludeStampDate Property
Gets or sets whether stamps added from now on carry the current date as a second line (see Avalonia.Controls.PdfViewer.StampDateFormat). The Stamp dropdown's "Include date" toggle sets this too. Default . Existing stamps keep their date, or their lack of one.
public bool IncludeStampDate { get; set; }
IsArrowKeyNudgeEnabled Property
Gets or sets whether the arrow keys move the selected annotation by one pixel (ten with
Shift) instead of navigating. Default true. With no annotation selected the arrow
keys always navigate. Also off when Avalonia.Controls.PdfViewer.EnableKeyboardShortcuts is false.
public bool IsArrowKeyNudgeEnabled { get; set; }
IsBookmarksEnabled Property
Gets or sets whether the Bookmarks sidebar pane is available. When its tab is hidden and the mode can't be selected. Default .
public bool IsBookmarksEnabled { get; set; }
IsDirty Property
Gets whether the document has edits (annotations, form values, redactions, bookmarks) that have not been written since it was loaded or last saved. Cleared by a successful Avalonia.Controls.PdfViewer.SaveAsync, Avalonia.Controls.PdfViewer.SaveDocumentAsync(System.IO.Stream) or auto-save and by loading another document. Undoing back to the saved state does not clear it.
public bool IsDirty { get; set; }
IsDrawToolVisible Property
Gets or sets whether the Draw (ink) tool is shown. Default .
public bool IsDrawToolVisible { get; set; }
IsHighlightToolVisible Property
Gets or sets whether the Highlight tool is shown. Default .
public bool IsHighlightToolVisible { get; set; }
IsLinkToolVisible Property
Gets or sets whether the Link tool is shown. Default .
public bool IsLinkToolVisible { get; set; }
IsLoading Property
Gets whether the control is currently loading a document.
public bool IsLoading { get; set; }
IsMobileLayout Property
Gets whether the touch-optimised mobile layout is used. When true, the annotation tools are relocated from the centre of the top toolbar to a dedicated bar along the bottom of the control; the search field, page navigation and menu stay in the top toolbar. The control manages this automatically — true on iOS/Android, or on any platform when the control is narrower than 500 device-independent pixels — recomputing as it resizes, so any value set externally is transient.
public bool IsMobileLayout { get; set; }
IsMoreOptionsVisible Property
Gets or sets whether the toolbar's More Options menu (print, share, view modes) is shown.
public bool IsMoreOptionsVisible { get; set; }
IsNoteToolVisible Property
Gets or sets whether the Note (sticky note) tool is shown. Default .
public bool IsNoteToolVisible { get; set; }
IsOpenVisible Property
Gets or sets whether an Open entry is offered at the top of the More Options menu. Off by default: most hosts load documents themselves. The entry runs Avalonia.Controls.PdfViewer.OpenAsync(System.Threading.CancellationToken).
public bool IsOpenVisible { get; set; }
IsPrintVisible Property
Gets or sets whether the Print entry is offered in the More Options menu. Even when
true the entry is hidden on platforms without a print service unless
Avalonia.Controls.PdfViewer.PrintRequested is handled.
public bool IsPrintVisible { get; set; }
IsReadOnly Property
Gets or sets a value that, when true, disables all document editing
(annotation tools and form input). Text selection and navigation remain available.
public bool IsReadOnly { get; set; }
IsRedactionUndoEnabled Property
Gets or sets whether redactions are recorded in the undo history. When false a
redaction is final as soon as it is applied and holds no document copy; other edits stay
undoable. Defaults to true.
public bool IsRedactionUndoEnabled { get; set; }
IsRedactToolVisible Property
Gets or sets whether the Redact tool is shown. Default .
public bool IsRedactToolVisible { get; set; }
IsSaveAsVisible Property
Gets or sets whether a Save As entry is offered in the More Options menu. Off by default. The entry runs Avalonia.Controls.PdfViewer.SaveAsAsync(System.Threading.CancellationToken).
public bool IsSaveAsVisible { get; set; }
IsSaveVisible Property
Gets or sets whether a Save entry (save in place, see Avalonia.Controls.PdfViewer.SaveAsync) is offered
in the More Options menu. Off by default; hidden anyway while
Avalonia.Controls.PdfViewer.AllowDocumentSaving is false.
public bool IsSaveVisible { get; set; }
IsShapeToolVisible Property
Gets or sets whether the Shapes tool is shown. Default .
public bool IsShapeToolVisible { get; set; }
IsShareVisible Property
Gets or sets whether the Share entry is offered in the More Options menu. Even when
true the entry is hidden on platforms without a share service unless
Avalonia.Controls.PdfViewer.ShareRequested is handled.
public bool IsShareVisible { get; set; }
IsSidebarOpen Property
Gets whether the sidebar is open (any mode other than None).
public bool IsSidebarOpen { get; set; }
IsSidebarVisible Property
Gets or sets whether the sidebar is visible (including collapsed state). When false, the sidebar is completely hidden and cannot be toggled.
public bool IsSidebarVisible { get; set; }
IsSquigglyToolVisible Property
Gets or sets whether the Squiggly tool is shown. Default .
public bool IsSquigglyToolVisible { get; set; }