From f910a47fd5680cb1b8441f1fcae46de121397a18 Mon Sep 17 00:00:00 2001 From: Silambharasan K Date: Wed, 8 Jul 2026 19:05:21 +0530 Subject: [PATCH 01/33] UG Document correction using Code-Studio AI --- .../maui/Add-Remove-Modify-Annotations.md | 32 ++++-- .../PDF-Viewer/maui/Annotation-Collection.md | 29 +++-- .../PDF-Viewer/maui/Annotations-Comment.md | 71 ++++++++---- .../PDF-Viewer/maui/Annotations-Overview.md | 37 +++--- .../PDF-Viewer/maui/Coordinates-Conversion.md | 46 +++++--- .../PDF/PDF-Viewer/maui/Custom-Bookmark.md | 60 +++++++--- .../maui/Document-Link-Annotations.md | 18 ++- .../PDF/PDF-Viewer/maui/Document-Outline.md | 36 ++++-- .../maui/DocumentLoadNotifications.md | 38 +++++-- .../maui/Form-Filling-Collection.md | 39 ++++--- .../maui/Form-Filling-Customization.md | 36 +++--- .../PDF/PDF-Viewer/maui/Form-Filling-Edit.md | 47 ++++---- .../PDF-Viewer/maui/Form-Filling-Events.md | 62 ++++++---- .../maui/Form-Filling-Import-Export.md | 73 ++++++++---- .../PDF-Viewer/maui/Form-Filling-Overview.md | 18 ++- .../PDF/PDF-Viewer/maui/Free-Text.md | 58 ++++++---- .../PDF/PDF-Viewer/maui/Getting-Started.md | 54 +++++---- .../PDF/PDF-Viewer/maui/Magnification.md | 32 ++++-- .../PDF/PDF-Viewer/maui/Overview.md | 68 +++++++---- .../PDF/PDF-Viewer/maui/Redaction.md | 107 +++++++++--------- .../PDF/PDF-Viewer/maui/Scrolling.md | 40 +++---- .../PDF/PDF-Viewer/maui/Shapes.md | 106 ++++++++--------- .../PDF/PDF-Viewer/maui/Undo-Redo.md | 27 +++-- .../PDF/PDF-Viewer/maui/ui-builder-skill.md | 81 ++++++------- 24 files changed, 758 insertions(+), 457 deletions(-) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Add-Remove-Modify-Annotations.md b/Document-Processing/PDF/PDF-Viewer/maui/Add-Remove-Modify-Annotations.md index 0091ebbe08..6612caba95 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Add-Remove-Modify-Annotations.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Add-Remove-Modify-Annotations.md @@ -10,15 +10,23 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne # Add, Remove, and Edit Annotations -This section will review the various functions in the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) for adding, removing, and editing annotations in a PDF document. +This section explains the various functions in the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) for adding, removing, and editing annotations in a PDF document. ## Add annotations to a PDF document -This section will go through how to add annotations to a PDF document programmatically. +This section explains how to add annotations to a PDF document programmatically. ### Add annotations programmatically -You can add a new annotation to the PDF document programmatically by creating an annotation instance and providing it as a parameter to the [AddAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AddAnnotation_Syncfusion_Maui_PdfViewer_Annotation_) method. The following example shows how to create an instance of a circle annotation and add it to the PDF document. Similarly, you can create and add other types of annotations. +You can add a new annotation to the PDF document programmatically by creating an annotation instance and providing it as a parameter to the [AddAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AddAnnotation_Syncfusion_Maui_PdfViewer_Annotation_) method. The following example shows how to create an instance of a circle annotation and add it to the PDF document. Similarly, you can create and add other types of annotations. For more information on the available annotation types, refer to the [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview). + +To work with annotations, ensure the following namespaces are imported in your code file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +{% endhighlight %} +{% endtabs %} {% tabs %} {% highlight c# %} @@ -65,7 +73,7 @@ private void OnAnnotationAdded(object sender, AnnotationEventArgs e) ## Remove annotations from the PDF document -This section will go through different methods of removing annotations from a PDF document. +This section explains different methods of removing annotations from a PDF document. ### Remove a specific annotation @@ -123,7 +131,7 @@ private void OnAnnotationRemoved(object sender, AnnotationEventArgs e) ## Edit annotations -This section will go through different methods of editing annotations in a PDF document programmatically. +This section explains different methods of editing annotations in a PDF document programmatically. The `AddAnnotation`, `RemoveAnnotation`, and property modifications on the annotations each raise their respective events: [AnnotationAdded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationAdded), [AnnotationRemoved](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationRemoved), and [AnnotationEdited](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationEdited). ### Edit a specific annotation @@ -174,14 +182,14 @@ private void OnAnnotationEdited(object sender, AnnotationEventArgs e) {% endhighlight %} {% endtabs %} -### Adding custom information to an annotation +## Adding custom information to an annotation -The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to assign custom information to annotations. The [CustomData](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.Annotation.html#Syncfusion_Maui_PdfViewer_Annotation_CustomData) property is utilized to store additional information about each annotation instance for reference. However, it's essential to note that these data are solely intended for reference purposes and will not be displayed in the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) interface. +The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to assign custom information to annotations. The [CustomData](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.Annotation.html#Syncfusion_Maui_PdfViewer_Annotation_CustomData) property is utilized to store additional information about each annotation instance for reference. However, it's essential to note that this data is solely intended for reference purposes and will not be displayed in the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) interface. -The provided code sample illustrates how to set the [CustomData](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.Annotation.html#Syncfusion_Maui_PdfViewer_Annotation_CustomData) property for an annotation. Within this code sample, we set the custom data to represent the creation date of the annotation. +The provided code sample illustrates how to set the [CustomData](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.Annotation.html#Syncfusion_Maui_PdfViewer_Annotation_CustomData) property for an annotation. In this code sample, the custom data is set to represent the creation date of the annotation. {% tabs %} -{% highlight C# %} +{% highlight c# %} private void OnAnnotationAdded(object sender, AnnotationEventArgs e) { @@ -196,3 +204,9 @@ private void OnAnnotationAdded(object sender, AnnotationEventArgs e) - [Select and Deselect Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/select-deselect-annotations) - [Import and Export Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/import-export-annotations) - [Undo and Redo](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/undo-redo) +- [Shapes](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/shapes) +- [Text Markups](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/text-markups) +- [Ink](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ink) +- [Signature](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/signature) +- [Stamps](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/stamps) +- [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Annotation-Collection.md b/Document-Processing/PDF/PDF-Viewer/maui/Annotation-Collection.md index d0fd992116..0d1e0eeeb2 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Annotation-Collection.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Annotation-Collection.md @@ -10,7 +10,19 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne # Annotation Collection in .NET MAUI PDF Viewer (SfPdfViewer) -The existing annotations in a PDF document can be accessed using the [Annotations](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_Annotations) property of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). This read only property will have the annotation collection information as soon as the document is loaded into the PDF Viewer. The following example explains how to use the property to obtain information about a square annotation that is the first on a specific document. +The existing annotations in a PDF document can be accessed using the [Annotations](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_Annotations) property of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). This read-only property will have the annotation collection information as soon as the document is loaded into the PDF Viewer. + +To work with the annotation collection, ensure the following namespaces are imported in your code file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +using Microsoft.Maui.Graphics; +using System.Collections.ObjectModel; +{% endhighlight %} +{% endtabs %} + +The following example explains how to use the property to obtain information about the first annotation in a specific document. {% tabs %} {% highlight c# %} @@ -42,7 +54,8 @@ private void OnDocumentLoaded(object sender, EventArgs e) {% endtabs %} ## AnnotationsLoaded event -The [AnnotationsLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationsLoaded) event occurs after all annotations in the PDF have finished loading, either when the document is opened or when annotations are imported. You can use this event to perform actions once annotations are fully available in the viewer. + +The [AnnotationsLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationsLoaded) event occurs after all annotations in the PDF have finished loading, either when the document is opened or when annotations are imported. The `AnnotationsLoaded` event fires after the [DocumentLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoaded) event, once all annotations are fully available in the viewer. You can use this event to perform actions once annotations are fully available in the viewer. The following example explains how to wire and handle the event. {% tabs %} @@ -51,10 +64,10 @@ The following example explains how to wire and handle the event. void WireAnnotationsLoadedEvent() { // Wire the annotations loaded event of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). - pdfViewer.AnnotationsLoaded += OnAnnotationsLoaded; + PdfViewer.AnnotationsLoaded += OnAnnotationsLoaded; } -private void OnAnnotationsLoaded(object? sender, EventArgs e) +private void OnAnnotationsLoaded(object sender, EventArgs e) { Debug.WriteLine("All annotations have been loaded."); } @@ -63,6 +76,8 @@ private void OnAnnotationsLoaded(object? sender, EventArgs e) {% endtabs %} ## See Also -- [Add, Remove, and Modify Annotations](../add-remove-modify-annotations) -- [Annotations Overview](../annotations-overview) -- [Select and Deselect Annotations](../select-deselect-annotations) +- [Add, Remove, and Edit Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/add-remove-modify-annotations) +- [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview) +- [Select and Deselect Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/select-deselect-annotations) +- [Import and Export Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/import-export-annotations) +- [Undo and Redo](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/undo-redo) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Annotations-Comment.md b/Document-Processing/PDF/PDF-Viewer/maui/Annotations-Comment.md index 23efabc7cb..f1dbf26573 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Annotations-Comment.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Annotations-Comment.md @@ -9,6 +9,7 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne --- # Comments in .NET MAUI PDF Viewer (SfPdfViewer) + The PDF Viewer control provides options to add, edit, and delete comments for the following annotations in PDF documents: 1. Ink annotation 2. Shape annotation @@ -18,8 +19,25 @@ The PDF Viewer control provides options to add, edit, and delete comments for th 6. Free text annotation 7. Signature annotation -## Showing/Hiding the Comment panel +## Showing or hiding the comment panel The built-in Comment Panel in the PDF Viewer displays annotation comments. You can show or hide this panel using the [IsCommentsPanelVisible](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_IsCommentsPanelVisible) property. The default value of this property is false. + +To work with the PDF Viewer and comments in code, ensure the following namespace is imported in your C# file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +{% endhighlight %} +{% endtabs %} + +To use the `SfPdfViewer` control in XAML, add the following namespace declaration to your XAML page: + +{% tabs %} +{% highlight xml %} +xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" +{% endhighlight %} +{% endtabs %} + {% tabs %} {% highlight c# %} @@ -30,7 +48,7 @@ PdfViewer.IsCommentsPanelVisible = true; {% endtabs %} {% tabs %} -{% highlight XAML %} +{% highlight xaml %} @@ -40,7 +58,8 @@ PdfViewer.IsCommentsPanelVisible = true; ## Comment panel -Annotation comments can be added to the PDF using the comment panel. Comment panel can be opened by using Built-in toolbar, In the toolbar you can see the comments button in the primary toolbar for desktop and top toolbar for mobile. The comment panel displays all annotations in the document along with their comments and replies, allowing you to add comments to any annotation and reply to existing comments or annotations. + +Annotation comments can be added to the PDF using the comment panel. The comment panel can be opened using the built-in toolbar. In the toolbar, you can find the Comments button in the primary toolbar for desktop and in the top toolbar for mobile. The comment panel displays all annotations in the document along with their comments and replies, allowing you to add comments to any annotation and reply to existing comments or annotations. The following image represents how to add the comments using the toolbar on the desktop. ![Annotations comments Built-in toolbar](Images/Annotations/desktop-comment.gif) @@ -50,16 +69,18 @@ The following image represents how to add comments using the toolbar on mobile. ![Annotations comments Built-in toolbar](Images/Annotations/mobile-comment.gif) ## Adding comments or replies -Follow these steps to add comments or replies : + +Follow these steps to add comments or replies: 1. Select the annotation in the PDF document and open the comment panel. 2. The corresponding comment thread is highlighted in the comment panel. -3. Add comments and replies using the comment panel. -4. Using the reply button in the comment panel, you can add a comment directly to a specific annotation, ensuring the discussion stays linked to that annotation. +3. Add a comment using the comment input area. +4. To reply to an existing comment or annotation, use the Reply button in the comment panel. This keeps the discussion linked to that annotation. 5. Multiple replies can be added to a comment. ## Add comments or replies programmatically -These can add comments or replies to existing annotations programmatically by accessing the specific annotation from the Annotations collection. This allows you to enhance collaboration and provide feedback directly within the PDF. -The following example explains how to add comments or replies to specific annotations in the PDF document. + +You can add comments or replies to existing annotations programmatically by accessing the specific annotation from the Annotations collection. This allows you to enhance collaboration and provide feedback directly within the PDF. +The following example explains how to add comments or replies to a specific annotation in the PDF document. {% tabs %} {% highlight c# %} @@ -77,22 +98,32 @@ annotation.Comments.Add(comment); {% endhighlight %} {% endtabs %} -## Editing the comments and comments replies of the annotations -Comments and replies can be edited through the context menu available under the More Options in the Comment Panel. Follow the steps below: -Select the annotation comment in the comment panel. +## Editing comments and replies + +Comments and replies can be edited through the context menu available under More Options in the Comment Panel. Follow the steps below: +1. Select the annotation comment in the comment panel. +2. Click More Options in the comment or reply container. +3. Select Edit from the context menu. +4. An editable text box appears. Change the content of the comment or reply. -1. Click More options in the comment or reply to container. -2. Select Edit from the context menu. -3. An editable text box appears. Change the content of the comment or reply. +## Deleting comments and replies -## Delete Comment or Comment Replies -Comments and replies can be deleted through the context menu available under the More Options in the Comment Panel. Follow the steps below: +Comments and replies can be deleted through the context menu available under More Options in the Comment Panel. Follow the steps below: 1. Select the annotation comment in the comment panel. -2. Click More options in the comment or reply to container. +2. Click More Options in the comment or reply container. 3. Select Delete from the context menu. -**Note :** Deleting the root comment from the comment panel also deletes the associated annotation. +**Note:** Deleting the root comment from the comment panel also deletes the associated annotation. ## See Also -- [Add, Remove, and Modify Annotations](../add-remove-modify-annotations) -- [Annotations Overview](../annotations-overview) +- [Add, Remove, and Edit Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/add-remove-modify-annotations) +- [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview) +- [Annotation Collection](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotation-collection) +- [Ink](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ink) +- [Shapes](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/shapes) +- [Stamps](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/stamps) +- [Sticky Notes](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/sticky-notes) +- [Free Text](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/free-text) +- [Text Markups](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/text-markups) +- [Signature](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/signature) +- [Toolbar](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/toolbar) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Annotations-Overview.md b/Document-Processing/PDF/PDF-Viewer/maui/Annotations-Overview.md index 81f8f00195..8efeadc59e 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Annotations-Overview.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Annotations-Overview.md @@ -18,11 +18,11 @@ To learn how to work with annotations, you can also check out our video tutorial -## Supported Annotation Types +## Supported annotation types The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) supports the following annotation types, grouped by category. -### Text Markup Annotations +### Text markup annotations Use these annotations to mark up text content within the PDF document. @@ -35,7 +35,7 @@ Use these annotations to mark up text content within the PDF document. For more information, see [Text Markup Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/text-markups). -### Shape Annotations +### Shape annotations Use these annotations to draw geometric shapes over PDF content. @@ -50,7 +50,9 @@ Use these annotations to draw geometric shapes over PDF content. For more information, see [Shape Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/shapes). -### Freehand and Rich Content Annotations +### Freehand and rich content annotations + +Use these annotations to draw freehand strokes or add rich content such as text boxes, stamps, and notes over PDF content. | Annotation | Description | |---|---| @@ -62,35 +64,24 @@ For more information, see [Shape Annotations](https://help.syncfusion.com/docume For more information, see [Ink Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ink), [Free Text Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/free-text), [Stamps](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/stamps), and [Sticky Notes](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/sticky-notes). -## In This Section - -### Annotation Types - -| Topic | Description | -|---|---| -| [Text Markup Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/text-markups) | Highlight, underline, strikeout, and squiggly annotations on selected text. | -| [Shape Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/shapes) | Draw arrows, circles, lines, polygons, polylines, and rectangles over pages. | -| [Ink Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ink) | Draw freehand strokes over any page area. | -| [Ink Eraser](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ink-eraser) | Erase portions of existing ink annotations. | -| [Free Text Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/free-text) | Place a text box directly on the page. | -| [Stamps](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/stamps) | Apply predefined or custom image stamps on a page. | -| [Sticky Notes](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/sticky-notes) | Attach pop-up notes to specific locations on a page. | +## Common annotation operations -### Common Annotation Operations +The following topics describe common operations that apply across annotation types. | Topic | Description | |---|---| -| [Add, Remove, and Modify Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/add-remove-modify-annotations) | Programmatically add, update, and delete any annotation type. | +| [Add, Remove, and Edit Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/add-remove-modify-annotations) | Programmatically add, update, and delete any annotation type. | | [Annotation Collection](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotation-collection) | Access and iterate the full annotation collection. | | [Select and Deselect Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/select-deselect-annotations) | Select one or more annotations programmatically. | | [Lock and Unlock Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/lock-unlock) | Prevent annotations from being edited or deleted. | | [Show and Hide Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/show-hide) | Toggle visibility of annotations without removing them. | | [Import and Export Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/import-export-annotations) | Import/export annotation data in XFDF, FDF, JSON, and XML formats. | | [Undo and Redo](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/undo-redo) | Reverse or reapply recent annotation changes. | -| [Annotation Comments](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-comment) | Add review comments and status to annotations. | +| [Comments](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-comment) | Add review comments and replies to annotations. | ## See Also -- [Add, Remove, and Modify Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/add-remove-modify-annotations) -- [Import and Export Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/import-export-annotations) + - [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document) -- [Undo and Redo](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/undo-redo) +- [Toolbar](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/toolbar) +- [Keyboard Shortcuts](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/keyboard-shortcuts) +- [UI Customization](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ui-customization) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Coordinates-Conversion.md b/Document-Processing/PDF/PDF-Viewer/maui/Coordinates-Conversion.md index 8802bc9bf6..d7237b396f 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Coordinates-Conversion.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Coordinates-Conversion.md @@ -12,11 +12,21 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne PDF Viewer allows users to obtain the PDF page coordinates relative to the PDF Viewer’s client coordinates and vice versa. It also allows you to obtain the scroll point relative to the PDF page coordinates and bring the given region into view. +To work with coordinate conversions, ensure the following namespaces are imported in your code file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +using Microsoft.Maui.Graphics; +using System.Collections.ObjectModel; +{% endhighlight %} +{% endtabs %} + ## Client rectangle -The [ClientRectangle](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ClientRectangle) in the MAUI PdfViewer control is a rectangular area that represents the dimensions of the client area or viewport. The client area denotes the visible portion of the PDF document within the control. In the MAUI PDF Viewer, this client rectangle is illustrated by the red rectangle in the following figure. +The [ClientRectangle](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ClientRectangle) in the MAUI PdfViewer control is a rectangular area that represents the dimensions of the client area or viewport. The client area denotes the visible portion of the PDF document within the control. In the MAUI PDF Viewer, this client rectangle is illustrated by the red rectangle in the following figure. -![Client rectangle in .NET MAUI PDF Viewer](Images\Coordinates-Conversion\Client-Rectangle.png) +![Client rectangle in .NET MAUI PDF Viewer](Images/Coordinates-Conversion/Client-Rectangle.png) The client rectangle can be obtained by the [ClientRectangle](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ClientRectangle) property of the PDF Viewer. The following code sample explains the same. @@ -29,9 +39,9 @@ Rect clientRectangle = PdfViewer.ClientRectangle; ## Client coordinates -The MAUI PDF Viewer specifies the position of points in the client area(viewport) using client coordinates. The upper-left corner of the client area (viewport) of the control is the origin for client coordinates. The client coordinates in the MAUI PDF Viewer are shown in the following figure. +The MAUI PDF Viewer specifies the position of points in the client area (viewport) using client coordinates. The upper-left corner of the client area (viewport) of the control is the origin for client coordinates. The client coordinates in the MAUI PDF Viewer are shown in the following figure. -![Client coordinates in .NET MAUI PDF Viewer](Images\Coordinates-Conversion\Client-Coordinates.png) +![Client coordinates in .NET MAUI PDF Viewer](Images/Coordinates-Conversion/Client-Coordinates.png) ### Get the page number from a client point @@ -55,15 +65,15 @@ private void PdfViewer_Tapped(object sender, GestureEventArgs e) ## PDF page coordinates -PDF page coordinates are represented in terms of a device-independent coordinate system called user space, which is independent of the output device that will be used for printing or display. The user space coordinates system is initialized to a default state for each page of a PDF document. The length of a unit is 1/72 inch, which is approximately the same as a unit of point(pt). As an example, the dimensions of a letter-sized paper in PDF page coordinates are shown in the diagram below. +PDF page coordinates are represented in terms of a device-independent coordinate system called user space, which is independent of the output device that will be used for printing or display. The user space coordinates system is initialized to a default state for each page of a PDF document. The length of a unit is 1/72 inch, which is equivalent to one point (pt). As an example, the dimensions of a letter-sized paper in PDF page coordinates are shown in the diagram below. -![Page coordinates in .NET MAUI PDF Viewer](Images\Coordinates-Conversion\Page-Coordinates.png) +![Page coordinates in .NET MAUI PDF Viewer](Images/Coordinates-Conversion/Page-Coordinates.png) ## Scroll coordinates -Scroll coordinates in the MAUI PdfViewer denote pixel-based positions as pages are scrolled, indicating precise locations within the entire document. The coordinate system originates from the top-left corner of the visible area. +Scroll coordinates in the MAUI PDF Viewer denote pixel-based positions as pages are scrolled. They indicate precise locations within the entire document. The coordinate system originates from the top-left corner of the visible area. -## Convert PDF Viewer’s coordinates to PDF page coordinates +## Convert PDF Viewer's coordinates to PDF page coordinates You can obtain the PDF page coordinates using the [ConvertClientPointToPagePoint(clientPoint, pageNumber)](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ConvertClientPointToPagePoint_Microsoft_Maui_Graphics_Point_System_Int32_) method by passing the client point and page number as input parameters. The following code sample explains how to convert a tapped client area position to a page point. @@ -85,9 +95,9 @@ private void PdfViewer_Tapped(object sender, GestureEventArgs e) {% endhighlight %} {% endtabs %} -## Convert PDF page coordinates to PDF Viewer’s coordinates +## Convert PDF page coordinates to PDF Viewer's coordinates -You can obtain the PDF Viewer’s coordinates using the [ConvertPagePointToClientPoint(pagePoint, pageNumber)](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ConvertPagePointToClientPoint_Microsoft_Maui_Graphics_Point_System_Int32_) method by passing the page point and page number as input parameters. The following code sample explains how to convert a square annotation’s position in the page coordinates to a client point. +You can obtain the PDF Viewer's coordinates using the [ConvertPagePointToClientPoint(pagePoint, pageNumber)](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ConvertPagePointToClientPoint_Microsoft_Maui_Graphics_Point_System_Int32_) method by passing the page point and page number as input parameters. The following code sample explains how to convert a square annotation's position in the page coordinates to a client point. {% tabs %} {% highlight c# %} @@ -100,7 +110,7 @@ Annotation annotation = annotations[0]; // Type cast to the specific annotation type. Here, the first annotation is a square annotation. if (annotation is SquareAnnotation squareAnnotation) { - //Get the annotation’s page number. + //Get the annotation's page number. int pageNumber = squareAnnotation.PageNumber; //Get the annotation bounds. RectF annotationBounds = squareAnnotation.Bounds; @@ -114,7 +124,7 @@ if (annotation is SquareAnnotation squareAnnotation) ## Convert PDF page coordinates to scroll coordinates -You can obtain the PDF Viewer’s scroll coordinates using the [ConvertPagePointToScrollPoint(pagePoint, pageNumber)](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ConvertPagePointToScrollPoint_Microsoft_Maui_Graphics_Point_System_Int32_) method by passing the page point and page number as input parameters. The following code example explains how to convert a square annotation’s position in the page coordinates to a scroll point. +You can obtain the PDF Viewer's scroll coordinates using the [ConvertPagePointToScrollPoint(pagePoint, pageNumber)](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ConvertPagePointToScrollPoint_Microsoft_Maui_Graphics_Point_System_Int32_) method by passing the page point and page number as input parameters. The following code example explains how to convert a square annotation's position in the page coordinates to a scroll point. {% tabs %} {% highlight c# %} @@ -129,7 +139,7 @@ if (annotation is SquareAnnotation squareAnnotation) { //Get the annotation bounds. RectF annotationBounds = squareAnnotation.Bounds; - //Get the annotation’s page number. + //Get the annotation's page number. int pageNumber = squareAnnotation.PageNumber; //Find the position of the annotation in page coordinates. Point pagePoint = new Point(annotationBounds.X, annotationBounds.Y); @@ -140,7 +150,11 @@ if (annotation is SquareAnnotation squareAnnotation) {% endtabs %} ## See Also -- [Annotations Overview](../annotations-overview) -- [Page Navigation](../page-navigation) -- [Scrolling](../scrolling) + +- [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview) +- [Page Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/page-navigation) +- [Scrolling](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/scrolling) +- [Add, Remove, and Edit Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/add-remove-modify-annotations) +- [Annotation Collection](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotation-collection) +- [Magnification](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/magnification) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Custom-Bookmark.md b/Document-Processing/PDF/PDF-Viewer/maui/Custom-Bookmark.md index 743750bcbb..70f7c4d901 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Custom-Bookmark.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Custom-Bookmark.md @@ -12,12 +12,32 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne PDF documents can include custom bookmarks that allow the user to bookmark pages and navigate to them. The PDF viewer control displays these custom bookmarks in outline view. -## Showing/Hiding the Custom Bookmarks Pane +To work with custom bookmarks in code, ensure the following namespaces are imported in your C# file: -The built-in custom bookmark view of the PDF Viewer displays the custom bookmarks, can be shown or hidden using the [IsOutlineViewVisible](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_IsOutlineViewVisible) property. The default value of this property is `false`. +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Linq; +{% endhighlight %} +{% endtabs %} + +To use the `SfPdfViewer` control in XAML, add the following namespace declaration to your XAML page: {% tabs %} -{% highlight XAML %} +{% highlight xml %} +xmlns:pdfViewer="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" +{% endhighlight %} +{% endtabs %} + +## Showing or hiding the custom bookmarks pane + +The built-in custom bookmark view of the PDF Viewer displays the custom bookmarks and can be shown or hidden using the [IsOutlineViewVisible](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_IsOutlineViewVisible) property. The default value of this property is `false`. + +{% tabs %} +{% highlight xml %} @@ -41,11 +61,11 @@ var customBookmarks = pdfViewer.CustomBookmarks; {% endhighlight %} {% endtabs %} -## Add, Edit, and Remove Custom Bookmarks +## Add, rename, and remove custom bookmarks -You can manage custom bookmarks in the PDF viewer using the [CustomBookmarks](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_CustomBookmarks) collection. This property allows you to add, edit, or remove bookmarks that appear in the viewer’s bookmark pane. +You can manage custom bookmarks in the PDF viewer using the [CustomBookmarks](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_CustomBookmarks) collection. This property allows you to add, rename, or remove bookmarks that appear in the viewer's bookmark pane. -### Add Custom Bookmarks +### Add custom bookmarks You can add custom bookmarks either through the UI or programmatically. You can also track additions using event handlers. @@ -108,11 +128,11 @@ private void Bookmarks_CollectionChanged(object? sender, NotifyCollectionChanged {% endhighlight %} {% endtabs %} -### Rename Custom Bookmarks +### Rename custom bookmarks You can rename custom bookmarks either through the UI or programmatically. You can also track rename changes using event handlers. -#### Rename via Context Menu +#### Rename via context menu To rename a custom bookmark from the UI: 1. Tap the context menu button on the desired custom bookmark. @@ -208,11 +228,11 @@ private void Bookmark_PropertyChanged(object? sender, PropertyChangedEventArgs e {% endhighlight %} {% endtabs %} -### Remove Custom Bookmarks +### Remove custom bookmarks You can remove custom bookmarks either through the UI or programmatically. You can also track bookmark removal using event handlers. -#### Remove via Context Menu +#### Remove via context menu To remove a custom bookmark from the UI: 1. Tap the context menu button on the custom bookmark you want to delete. @@ -245,9 +265,9 @@ To track when a custom bookmark is removed, handle the [CollectionChanged](https private void Bookmarks_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { // Check if the change action is 'Remove' - else if (e.Action == NotifyCollectionChangedAction.Remove && e.OldItems != null) + if (e.Action == NotifyCollectionChangedAction.Remove && e.OldItems != null) { - // Iterate through reomoved bookmarks + // Iterate through removed bookmarks foreach (Bookmark bookmark in e.OldItems) { Debug.WriteLine($"Removed bookmark: {bookmark.Name} at page {bookmark.PageNumber}"); @@ -262,7 +282,7 @@ private void Bookmarks_CollectionChanged(object? sender, NotifyCollectionChanged You can navigate to custom bookmarks either through the UI or programmatically using the PDF viewer's built-in features. -### Navigate Using UI +### Navigate using UI To navigate using the UI: 1. Ensure the outline view is visible by setting the [IsOutlineViewVisible](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_IsOutlineViewVisible) property to `true`. @@ -270,8 +290,9 @@ To navigate using the UI: ![Custom bookmark in .NET MAUI PDF Viewer](Images\custom-bookmark.png) -N>A custom bookmark currently stores only the target page information. It does not support storing or navigating to a specific position within the page, such as coordinates or a particular content region. -### Navigate Programmatically +**Note:** A custom bookmark currently stores only the target page information. It does not support storing or navigating to a specific position within the page, such as coordinates or a particular content region. + +### Navigate programmatically To navigate to a custom bookmark programmatically, use the [GoToBookmark](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_GoToBookmark_Syncfusion_Maui_PdfViewer_Bookmark_) method. This method accepts a `Bookmark` object and navigates to the page associated with it. @@ -288,6 +309,9 @@ if (customBookmark != null) {% endtabs %} ## See Also -- [Document Outline](../document-outline) -- [Page Navigation](../page-navigation) -- [Hyperlink Navigation](../hyperlink-navigation) + +- [Document Outline](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/document-outline) +- [Page Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/page-navigation) +- [Hyperlink Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/hyperlink-navigation) +- [Annotation Collection](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotation-collection) +- [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Document-Link-Annotations.md b/Document-Processing/PDF/PDF-Viewer/maui/Document-Link-Annotations.md index b368ca412a..e68ec702fb 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Document-Link-Annotations.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Document-Link-Annotations.md @@ -10,13 +10,21 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne # Document Link Navigation in .NET MAUI PDF Viewer (SfPdfViewer) -The PDF viewer allows navigating from one part of the PDF document to another using document link annotations. When a document link annotation is tapped, the PDF viewer scrolls to the destination page or location defined by that annotation. This type of annotation is most commonly used to make a PDF's table of contents interactive — each entry links directly to the corresponding page in the document. +The PDF Viewer allows navigating from one part of the PDF document to another using document link annotations. When a document link annotation is tapped, the PDF Viewer scrolls to the destination page or location defined by that annotation. This type of annotation is most commonly used to make a PDF's table of contents interactive — each entry links directly to the corresponding page in the document. + +To work with document link navigation in code, ensure the following namespace is imported in your C# file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +{% endhighlight %} +{% endtabs %} ![TOC Navigation](Images/TOCNavigation.gif) -N> Document link annotations differ from hyperlink annotations. Document links navigate **within** the same PDF document, while hyperlinks open an external URL in the device browser. See [Hyperlink Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/hyperlink-navigation) for details on handling external links. +**Note:** Document link annotations differ from hyperlink annotations. Document links navigate **within** the same PDF document, while hyperlinks open an external URL in the device browser. See [Hyperlink Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/hyperlink-navigation) for details on handling external links. -## Enable or Disable Document Link Navigation +## Enable or disable document link navigation The document link navigation can be turned on or off using the [EnableDocumentLinkNavigation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_EnableDocumentLinkNavigation) property. The default value of this property is `true`. The code snippet below illustrates disabling the document link navigation. @@ -29,6 +37,10 @@ pdfViewer.EnableDocumentLinkNavigation = false; {% endtabs %} ## See Also + - [Hyperlink Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/hyperlink-navigation) - [Page Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/page-navigation) - [Document Outline (Bookmarks)](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/document-outline) +- [Custom Bookmarks](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/custom-bookmark) +- [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview) +- [Toolbar](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/toolbar) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Document-Outline.md b/Document-Processing/PDF/PDF-Viewer/maui/Document-Outline.md index d0ad9cc1c3..449a9bcdda 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Document-Outline.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Document-Outline.md @@ -12,9 +12,26 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne A PDF document may optionally have a document outline (also called bookmarks) which allows the user to navigate from one part of the document to another. The PDF viewer control displays the document outline in a tree-structured hierarchy of outline elements. -## Showing/hiding the outline view +To work with the document outline in code, ensure the following namespaces are imported in your C# file: -The PDF viewer’s built-in outline view that displays the document outline in a tree like structure can be shown or hidden using the [IsOutlineViewVisible](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_IsOutlineViewVisible) property. The default value of this property is `false`. +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +using System.Linq; +{% endhighlight %} +{% endtabs %} + +To use the `SfPdfViewer` control in XAML, add the following namespace declaration to your XAML page: + +{% tabs %} +{% highlight xml %} +xmlns:pdfViewer="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" +{% endhighlight %} +{% endtabs %} + +## Showing / hiding the outline view + +The PDF Viewer's built-in outline view, which displays the document outline in a tree-like structure, can be shown or hidden using the [IsOutlineViewVisible](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_IsOutlineViewVisible) property. The default value of this property is `false`. {% tabs %} {% highlight XAML %} @@ -43,7 +60,7 @@ var documentOutline = pdfViewer.DocumentOutline; ## Accessing nested child elements -The outline elements nested within each outline element can be accessed from the [OutlineElement.Children](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.OutlineElement.html#Syncfusion_Maui_PdfViewer_OutlineElement_Children) property. Below code snippet illustrates accessing the 2nd element in the document outline. And then accessing its 3rd child. +The outline elements nested within each outline element can be accessed from the [OutlineElement.Children](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.OutlineElement.html#Syncfusion_Maui_PdfViewer_OutlineElement_Children) property. The following code snippet illustrates accessing the third element in the document outline and then accessing its fourth child (using zero-based indexing). {% tabs %} {% highlight c# %} @@ -56,15 +73,15 @@ OutlineElement nestedElement = outlineElement.Children[3]; ## Navigating to outline elements -### Navigating using UI +### Navigating using the UI -As mentioned above, you can show the outline view by setting the [IsOutlineViewVisible](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_IsOutlineViewVisible) property to `true`. When the outline view is showing, you can tap on any element to navigate to the destination pointed by that element. +After showing the outline view using the [IsOutlineViewVisible](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_IsOutlineViewVisible) property as described above, you can tap on any element to navigate to the destination pointed to by that element. -![Document outline in .NET MAUI PDF Viewer](Images\outline-view.png) +![Document outline in .NET MAUI PDF Viewer](Images/outline-view.png) ### Navigating programmatically -The PDF viewer allows the users to navigate to an outline element using the [GoToOutlineElement](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_GoToOutlineElement_Syncfusion_Maui_PdfViewer_OutlineElement_) method. The below code snippet illustrates the same. +The PDF Viewer allows users to navigate to an outline element using the [GoToOutlineElement](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_GoToOutlineElement_Syncfusion_Maui_PdfViewer_OutlineElement_) method. The following code snippet illustrates how to navigate to an outline element. {% tabs %} {% highlight c# %} @@ -79,6 +96,9 @@ if (outlineElement != null) {% endtabs %} ## See Also + - [Page Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/page-navigation) - [Document Link Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/document-link-annotations) -- [Custom Bookmark](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/custom-bookmark) +- [Custom Bookmarks](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/custom-bookmark) +- [Hyperlink Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/hyperlink-navigation) +- [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/DocumentLoadNotifications.md b/Document-Processing/PDF/PDF-Viewer/maui/DocumentLoadNotifications.md index cc3c1cd34c..ef0c01ff02 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/DocumentLoadNotifications.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/DocumentLoadNotifications.md @@ -12,6 +12,22 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) supports the [DocumentLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoaded) and [DocumentLoadFailed](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoadFailed) events to notify whether the document has been opened and displayed in the view or not. +To work with document load events in code, ensure the following namespace is imported in your C# file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +{% endhighlight %} +{% endtabs %} + +To use the `SfPdfViewer` control in XAML, add the following namespace declaration to your XAML page: + +{% tabs %} +{% highlight XAML %} +xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" +{% endhighlight %} +{% endtabs %} + ## Document loaded event The [DocumentLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoaded) event triggers after the document is loaded in the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). Refer to the following code example: @@ -24,7 +40,7 @@ The [DocumentLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfView DocumentLoaded="PdfViewer_DocumentLoaded"/> {% endhighlight %} -{% highlight C# %} +{% highlight c# %} private void PdfViewer_DocumentLoaded(object sender, EventArgs e) { @@ -37,11 +53,11 @@ The [DocumentLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfView If you want to perform any operation immediately after the document has loaded, you can handle the operations in this event. For example, if you want to initially open a document with a specific page number or zoom factor, then call the respective APIs in this event handler. The following code example explains opening a document with a specified page number of 4. {% tabs %} -{% highlight C# %} +{% highlight c# %} private void PdfViewer_DocumentLoaded(object sender, EventArgs e) { - pdfViewer.GoToPage(4); + PdfViewer.GoToPage(4); } {% endhighlight %} @@ -49,18 +65,18 @@ private void PdfViewer_DocumentLoaded(object sender, EventArgs e) ## Document load failures -When a document fails to load in the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html), users are notified with a context-specific error message via the [DocumentLoadFailed](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoadFailed) event. This event helps developers identify the cause of the failure and implement custom error handling for a smoother user experience. +When a document fails to load in the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html), the [DocumentLoadFailed](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoadFailed) event notifies the application with a context-specific error message. This event helps developers identify the cause of the failure and implement custom error handling for a smoother user experience. ### Document load failed event The [DocumentLoadFailed](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoadFailed) event alerts users when a document fails to load in the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) due to one of the following conditions: * A corrupted document is loaded. * A password-protected document is provided with an invalid or empty password. -* A non-PDF file is attempted to be loaded. +* A non-PDF file is loaded. * The document contains an XFA form, which is currently unsupported. * Exceptions occur during PDF loading or page rendering due to limitations or issues in platform-specific native PDF renderers. -The [DocumentLoadFailedEventArgs](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.DocumentLoadFailedEventArgs.html) will return the error [Message](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.DocumentLoadFailedEventArgs.html#Syncfusion_Maui_PdfViewer_DocumentLoadFailedEventArgs_Message) and [Exception](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.DocumentLoadFailedEventArgs.html#Syncfusion_Maui_PdfViewer_DocumentLoadFailedEventArgs_Exception) details for the failure. The following code example explains the same. +The [DocumentLoadFailedEventArgs](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.DocumentLoadFailedEventArgs.html) returns the error [Message](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.DocumentLoadFailedEventArgs.html#Syncfusion_Maui_PdfViewer_DocumentLoadFailedEventArgs_Message) and [Exception](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.DocumentLoadFailedEventArgs.html#Syncfusion_Maui_PdfViewer_DocumentLoadFailedEventArgs_Exception) details for the failure. The following code example explains how to handle the event. {% tabs %} {% highlight XAML hl_lines="3" %} @@ -70,7 +86,7 @@ The [DocumentLoadFailedEventArgs](https://help.syncfusion.com/cr/maui/Syncfusion DocumentLoadFailed="PdfViewer_DocumentLoadFailed"/> {% endhighlight %} -{% highlight C# %} +{% highlight c# %} private void PdfViewer_DocumentLoadFailed(object sender, DocumentLoadFailedEventArgs e) { @@ -82,7 +98,7 @@ private void PdfViewer_DocumentLoadFailed(object sender, DocumentLoadFailedEvent ### Handling document load failures -The [DocumentLoadFailed](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoadFailed) event allows you to handle the load failures at the application level in your own way. Set the [Handled](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.DocumentLoadFailedEventArgs.html#Syncfusion_Maui_PdfViewer_DocumentLoadFailedEventArgs_Handled) property of the [DocumentLoadFailedEventArgs](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.DocumentLoadFailedEventArgs.html) to `true` to disable the control’s default error messages and handle your logic with the error information. +By default, the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) displays its own error message when a document fails to load. If you prefer to handle the failure at the application level with custom logic instead, set the [Handled](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.DocumentLoadFailedEventArgs.html#Syncfusion_Maui_PdfViewer_DocumentLoadFailedEventArgs_Handled) property of the [DocumentLoadFailedEventArgs](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.DocumentLoadFailedEventArgs.html) to `true` to suppress the control's default error messages and implement your own handling using the error information. {% tabs %} {% highlight XAML hl_lines="3" %} @@ -92,7 +108,7 @@ The [DocumentLoadFailed](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Pdf DocumentLoadFailed="PdfDocumentLoadFailed"/> {% endhighlight %} -{% highlight C# hl_lines="4" %} +{% highlight c# hl_lines="4" %} public MainPage() { @@ -110,6 +126,10 @@ private void PdfDocumentLoadFailed(object sender, DocumentLoadFailedEventArgs e) {% endtabs %} ## See Also + - [Open a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/open-a-document) +- [Open a Password Protected Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/open-a-password-protected-document) - [Getting Started](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/getting-started) - [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document) +- [Page Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/page-navigation) +- [Magnification](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/magnification) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Collection.md b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Collection.md index 3a1774c759..b243fcd7c9 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Collection.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Collection.md @@ -10,21 +10,30 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne # Form Fields Collection in .NET MAUI PDF Viewer (SfPdfViewer) -The [SfPdfViewer.FormFields](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FormFields) property provides access to all form fields present in the loaded PDF document. The collection is available after the document finishes loading and can be accessed from the [DocumentLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoaded) event. +The [SfPdfViewer.FormFields](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FormFields) property provides access to all form fields present in the loaded PDF document. The collection is available after the document finishes loading and can be accessed from the [DocumentLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoaded) event. For a broader overview of form-filling support, see [Form Filling Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-overview). + +To work with form fields in code, ensure the following namespaces are imported in your C# file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +using System.Linq; +{% endhighlight %} +{% endtabs %} ## Accessing the FormFields collection -The following code snippet illustrates getting the total count of form fields in the PDF document. +The following code snippet illustrates getting the total count of form fields in the PDF document. Call the `WireDocumentLoadedEvent` method from your page constructor or initialization logic so the `DocumentLoaded` handler is registered before a document is loaded. {% tabs %} -{% highlight C# %} +{% highlight c# %} public void WireDocumentLoadedEvent() { // Wire the document loaded event to occur when a PDF document is loaded. PdfViewer.DocumentLoaded += OnDocumentLoaded; } -private void OnDocumentLoaded(object? sender, EventArgs? e) +private void OnDocumentLoaded(object sender, EventArgs e) { // Get the form field count. int fieldCount = PdfViewer.FormFields.Count; @@ -34,10 +43,10 @@ private void OnDocumentLoaded(object? sender, EventArgs? e) ## Retrieve a specific form field by name -You can retrieve a specific form field from the collection by filtering on the [Name](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.FormField.html#Syncfusion_Maui_PdfViewer_FormField_Name) property. The following example retrieves a text form field named `"name"`. +You can retrieve a specific form field from the collection by filtering on the [Name](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.FormField.html#Syncfusion_Maui_PdfViewer_FormField_Name) property. The following example retrieves a text form field whose name is `name`. {% tabs %} -{% highlight C# %} +{% highlight c# %} FormField formField = PdfViewer.FormFields.Where(x => x.Name == "name").FirstOrDefault(); if (formField is TextFormField nameTextBox) @@ -52,7 +61,7 @@ if (formField is TextFormField nameTextBox) Form fields can be prevented from being modified by setting the [ReadOnly](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.FormField.html#Syncfusion_Maui_PdfViewer_FormField_ReadOnly) property to `true`. The following example makes all form fields read-only. {% tabs %} -{% highlight C# %} +{% highlight c# %} // Restrict editing of all form fields. foreach (FormField formField in PdfViewer.FormFields) { @@ -66,7 +75,7 @@ foreach (FormField formField in PdfViewer.FormFields) The [ClearFormData](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ClearFormData_System_Int32_) method clears the data in all form fields in the PDF document. {% tabs %} -{% highlight C# %} +{% highlight c# %} // Clear all form field data in the document. PdfViewer.ClearFormData(); {% endhighlight %} @@ -75,7 +84,7 @@ PdfViewer.ClearFormData(); To clear form data on a specific page, pass the page number to the method. {% tabs %} -{% highlight C# %} +{% highlight c# %} // Clear all form field data on page 2. PdfViewer.ClearFormData(2); {% endhighlight %} @@ -83,12 +92,12 @@ PdfViewer.ClearFormData(2); ## Attach custom data to a form field -The [CustomData](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.FormField.html#Syncfusion_Maui_PdfViewer_FormField_CustomData) property allows you to store additional reference information on any form field instance. This data is for application use only and is not displayed or saved in the PDF document. +The [CustomData](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.FormField.html#Syncfusion_Maui_PdfViewer_FormField_CustomData) property allows you to store additional reference information for any form field instance. This data is for application use only and is not displayed or saved in the PDF document. To use this example, wire the `FormFieldValueChanged` event of the `SfPdfViewer` (for more details, see [Form Field Events](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-events)). -The following example stores the modification timestamp on a form field whenever its value changes. +The following example stores the modification timestamp for a form field whenever its value changes. {% tabs %} -{% highlight C# %} +{% highlight c# %} private void PdfViewer_FormFieldValueChanged(object sender, FormFieldValueChangedEventArgs e) { e.FormField.CustomData = "Modified: " + DateTime.Now.ToString(); @@ -97,7 +106,11 @@ private void PdfViewer_FormFieldValueChanged(object sender, FormFieldValueChange {% endtabs %} ## See Also + - [Form Filling Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-overview) - [Edit Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-edit) - [Show and Hide Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-show-hide) -- [Form Field Events](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-events) \ No newline at end of file +- [Form Field Events](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-events) +- [Import and Export Form Data](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-import-export) +- [Form Field Validation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-validation) +- [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document) \ No newline at end of file diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Customization.md b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Customization.md index a81ae9514f..d7d7ac2eaa 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Customization.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Customization.md @@ -8,20 +8,21 @@ documentation: ug keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .net maui open pdf, maui pdf viewer, maui pdf view --- -# Customize Form Fields in .NET MAUI PDF Viewer (SfPdfViewer) +# Customize form fields in .NET MAUI PDF Viewer (SfPdfViewer) -The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to customize the visual appearance of form fields by modifying properties on their [Widget](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.Widget.html) objects. You can change the background color, text (foreground) color, border color, and border width. +The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to customize the visual appearance of form fields by modifying properties on their [Widget](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.Widget.html) objects. A form field can have one or more `Widget` instances (the visual representations of the field on the page). You can change the background color, foreground (text) color, border color, and border width. -N> * Appearance customizations support undo and redo. -N> * Customizations cannot be applied when a form field is locked. -N> * Customized colors and border width are preserved during import, export, printing, and saving. +**Note:** +* Appearance customizations support undo and redo. +* Customizations cannot be applied when a form field is locked. For details, see [Lock and Unlock Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/lock-unlock). +* Customized colors and border width are preserved during import, export, printing, and saving. For more information, see [Import and Export Form Data](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-import-export) and [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document). ## Customize the background color The [BackgroundColor](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.Widget.html#Syncfusion_Maui_PdfViewer_Widget_BackgroundColor) property sets the fill color behind the field content. The following example applies a uniform background color to all form fields in the document. {% tabs %} -{% highlight C# %} +{% highlight c# %} foreach (FormField formField in PdfViewer.FormFields) { foreach (Widget widget in formField.Widgets) @@ -33,12 +34,12 @@ foreach (FormField formField in PdfViewer.FormFields) {% endhighlight %} {% endtabs %} -## Customize the text color +## Customize the foreground (text) color -The `ForegroundColor` property sets the text color inside the form field. The following example applies a red text color to all text form fields. +The `ForegroundColor` property sets the color of the text inside the form field. The following example applies a red text color to all text form fields. {% tabs %} -{% highlight C# %} +{% highlight c# %} foreach (FormField formField in PdfViewer.FormFields) { if (formField is TextFormField textBoxField) @@ -57,7 +58,7 @@ foreach (FormField formField in PdfViewer.FormFields) The `BorderColor` property sets the color of the border drawn around the form field. The following example applies a red border to all text form fields. {% tabs %} -{% highlight C# %} +{% highlight c# %} foreach (FormField formField in PdfViewer.FormFields) { if (formField is TextFormField textBoxField) @@ -76,7 +77,7 @@ foreach (FormField formField in PdfViewer.FormFields) The `BorderWidth` property sets the thickness of the border around the form field. The following example sets a border width of `2.0` on all text form fields. {% tabs %} -{% highlight C# %} +{% highlight c# %} foreach (FormField formField in PdfViewer.FormFields) { if (formField is TextFormField textBoxField) @@ -92,13 +93,13 @@ foreach (FormField formField in PdfViewer.FormFields) ## Detect widget property changes -The `PropertyChanged` event on a [Widget](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.Widget.html) fires whenever a widget property — such as `BorderColor`, `BackgroundColor`, `BorderWidth`, or `ForegroundColor` — changes. Subscribe to this event after the document loads. +In addition to setting widget properties, you can also track when a widget property changes at runtime. The `PropertyChanged` event on a [Widget](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.Widget.html) fires whenever a widget property — such as `BorderColor`, `BackgroundColor`, `BorderWidth`, or `ForegroundColor` — changes. Subscribe to this event after the document loads. {% tabs %} -{% highlight C# %} +{% highlight c# %} void SubscribeToWidgetPropertyChanges() { - foreach (FormField formField in pdfViewer.FormFields) + foreach (FormField formField in PdfViewer.FormFields) { foreach (var widget in formField.Widgets) { @@ -107,7 +108,7 @@ void SubscribeToWidgetPropertyChanges() } } -private void Widget_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) +private void Widget_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (sender is Widget widget) { @@ -122,7 +123,12 @@ private void Widget_PropertyChanged(object? sender, System.ComponentModel.Proper {% endtabs %} ## See Also + - [Form Filling Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-overview) - [Show and Hide Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-show-hide) - [Form Fields Collection](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-collection) - [Form Field Events](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-events) +- [Edit Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-edit) +- [Import and Export Form Data](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-import-export) +- [Lock and Unlock](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/lock-unlock) +- [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Edit.md b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Edit.md index 8fe6013bba..35c06bcda9 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Edit.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Edit.md @@ -14,7 +14,7 @@ The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer. ## Editing form fields programmatically -All form field edits shown below should be placed in your page's code-behind (`MainPage.xaml.cs`). The document must be fully loaded before accessing [FormFields](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FormFields) — call these from the [DocumentLoaded](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoaded") event handler or a button click after the document is open. +All form field edits shown below should be placed in your page's code-behind (`MainPage.xaml.cs`). The document must be fully loaded before accessing [FormFields](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FormFields) — call these from the [DocumentLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoaded) event handler or a button click handler after the document is open. ### Editing text form fields @@ -23,8 +23,8 @@ A text form field can be modified using the [Text](https://help.syncfusion.com/c {% tabs %} {% highlight C# tabtitle="MainPage.xaml.cs" %} -// Call after DocumentLoaded fires, or from a button_Clicked handler. -FormField formField = pdfViewer.FormFields.Where(x => x.Name == "name").FirstOrDefault(); +// Call after the DocumentLoaded event fires, or from an OnEditButtonClicked handler. +FormField formField = PdfViewer.FormFields.Where(x => x.Name == "name").FirstOrDefault(); if (formField is TextFormField nameTextBox) { @@ -124,7 +124,7 @@ if (formField is RadioButtonFormField radioButton) ### Editing signature form fields -Programmatically, add a signature to an unsigned signature field by creating and assigning an ink annotation to the [SignatureFormField.Signature](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SignatureFormField.html#Syncfusion_Maui_PdfViewer_SignatureFormField_Signature) property. The following code snippet illustrates retrieving a signature form field named "signature" from the PDF Viewer. +You can programmatically add a signature to an unsigned signature field by creating and assigning an ink annotation to the [SignatureFormField.Signature](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SignatureFormField.html#Syncfusion_Maui_PdfViewer_SignatureFormField_Signature) property. The following code snippet illustrates retrieving a signature form field named "signature" from the PDF Viewer. {% tabs %} {% highlight C# %} @@ -143,21 +143,21 @@ if (signature != null) {% endhighlight %} {% endtabs %} -The [Signature](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SignatureFormField.html#Syncfusion_Maui_PdfViewer_SignatureFormField_Signature) property is of type [InkAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.InkAnnotation.html) and it will behave like an ink after signing. If the PDF document is saved, the signature will be preserved as an ink annotation in the saved document. +The [Signature](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SignatureFormField.html#Syncfusion_Maui_PdfViewer_SignatureFormField_Signature) property is of type [InkAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.InkAnnotation.html) and it behaves like an ink annotation after signing. If the PDF document is saved, the signature will be preserved as an ink annotation in the saved document. #### Suppressing the signature modal view -The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to suppress the signature modal view and use your own UI in its place. This can be achieved by setting the `FormFieldModalViewAppearingEventArgs.Cancel` property to `true` in the [SignatureModalViewAppearing](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_SignatureModalViewAppearing) event handler. +The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to suppress the signature modal view and use your own UI in its place. This can be achieved by setting the `FormFieldModalViewAppearingEventArgs.Cancel` property to `true` in the [SignatureModalViewAppearing](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_SignatureModalViewAppearing) event handler. -The below code snippet illustrates suppressing the signature modal view and using a UI implemented in the app in its place. In this illustration, it is assumed that the signature is produced in the form of an image stream when the user completes drawing the signature in the custom dialog. When the signing is completed using the custom dialog, a stamp annotation is created and assigned as the signature of the form field. +The following code snippet illustrates suppressing the signature modal view and using a UI implemented in the app in its place. In this illustration, it is assumed that the signature is produced in the form of an image stream when the user completes drawing the signature in the custom dialog. When the signing is completed using the custom dialog, a stamp annotation is created and assigned as the signature of the form field. {% tabs %} {% highlight c# %} SignatureFormField? signatureFormField; -pdfviewer.SignatureModalViewAppearing += PdfViewer_SignatureModalViewAppearing; +PdfViewer.SignatureModalViewAppearing += PdfViewer_SignatureModalViewAppearing; -private void PdfViewer_SignatureModalViewAppearing(object? Sender, FormFieldModalViewAppearingEventArgs e) +private void PdfViewer_SignatureModalViewAppearing(object? sender, FormFieldModalViewAppearingEventArgs e) { e.Cancel = true; signatureFormField = e.FormField as SignatureFormField; @@ -166,10 +166,10 @@ private void PdfViewer_SignatureModalViewAppearing(object? Sender, FormFieldModa ShowCustomDialog(); } -Private void customDialogOkButton_Clicked(object sender, EventArgs e) +private void customDialogOkButton_Clicked(object sender, EventArgs e) { //Get the signature in the form of a Stream instance (possibly converted from an image of the user's freehand drawing) - signatureImageStream = GetSignatureImageStream(); + Stream signatureImageStream = GetSignatureImageStream(); // Create a stamp annotation. The bounds values are not necessary since the stamp will be automatically fit over the signature form field. StampAnnotation signatureStamp = new StampAnnotation(signatureImageStream, signatureFormField.PageNumber, new RectF(0, 0, 0, 0)); @@ -180,13 +180,13 @@ Private void customDialogOkButton_Clicked(object sender, EventArgs e) {% endhighlight %} {% endtabs %} -### Button form fields +### Button form fields behavior -Button form fields will be rendered in the PDF viewer. But the PDF viewer supports only the `GoTo` actions that navigates to a particular location in the PDF document alone. Other types of button actions are not supported. +Button form fields will be rendered in the PDF Viewer. The PDF Viewer supports only the `GoTo` actions that navigate to a particular location in the PDF document. Other types of button actions are not supported. ## Flatten form fields only on save -The [FlattenOnSave](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.FormField.html#Syncfusion_Maui_PdfViewer_FormField_FlattenOnSave) property converts form fields into non-editable content only when the PDF document is saved. This means the form fields remain editable while the document is open, and are flattened (made part of the document content) during the save operation, preventing any further modification afterward. +The [FlattenOnSave](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.FormField.html#Syncfusion_Maui_PdfViewer_FormField_FlattenOnSave) property converts form fields into non-editable content only when the PDF document is saved. This means the form fields remain editable while the document is open, and are flattened (made part of the document content) during the save operation, preventing any further modification afterward. ### Flatten specific form fields @@ -195,7 +195,7 @@ You can selectively flatten specific form fields, such as signature fields, by i {% tabs %} {% highlight c# %} -foreach (var item in pdfViewer.FormFields) +foreach (var item in PdfViewer.FormFields) { //Iterate Only signature form field and flatten it if (item is SignatureFormField signature) @@ -215,7 +215,7 @@ To flatten all form fields in the document, set the FlattenOnSave property for e {% highlight c# %} //Iterate all the form fields and set flatten -foreach (var item in pdfViewer.FormFields) +foreach (var item in PdfViewer.FormFields) { item.FlattenOnSave = true; } @@ -223,7 +223,7 @@ foreach (var item in pdfViewer.FormFields) {% endhighlight %} {% endtabs %} -## Controlling form field editing at the viewer Level +## Controlling form field editing at the viewer level The `AllowEditFormFields` property is used to control form field editing at the viewer level. By default, editing is enabled, allowing users to interact with all supported form fields. When this property is set to false, all form fields become non-editable, making the document effectively read-only without modifying individual field properties. This behavior applies to all form field types and takes effect immediately on the loaded document. @@ -238,15 +238,16 @@ You can disable editing programmatically using the following: {% highlight c# %} // Disable form field editing -pdfViewer.AllowEditFormFields = false; +PdfViewer.AllowEditFormFields = false; {% endhighlight %} {% endtabs %} This property supports dynamic changes at runtime, meaning you can enable or disable form field editing at the viewer level based on requirements, and the changes will be applied instantly. -N>Setting AllowEditFormFields to false does not modify the ReadOnly property of individual form fields. It acts as an additional layer of control, and a field remains non-editable if either its ReadOnly property is true or viewer-level editing is disabled +**Note:** Setting `AllowEditFormFields` to false does not modify the `ReadOnly` property of individual form fields. It acts as an additional layer of control, and a field remains non-editable if either its `ReadOnly` property is true or viewer-level editing is disabled. ## See Also + - [Form Filling Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-overview) - [Form Fields Collection](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-collection) - [Show and Hide Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-show-hide) @@ -254,3 +255,11 @@ N>Setting AllowEditFormFields to false does not modify the ReadOnly property of - [Form Field Events](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-events) - [Import and Export Form Data](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-import-export) - [Electronic Signature](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/signature) +- [Form Field Validation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-validation) +- [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document) +- [Form Fields Collection](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-collection) +- [Show and Hide Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-show-hide) +- [Customize Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-customization) +- [Form Field Events](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-events) +- [Import and Export Form Data](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-import-export) +- [Electronic Signature](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/signature) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Events.md b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Events.md index 8dff6e7771..becd51ead7 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Events.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Events.md @@ -10,7 +10,28 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne # Form Field Events in .NET MAUI PDF Viewer (SfPdfViewer) -The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) exposes events that allow you to track and respond to user interactions with form fields, such as value changes and focus changes. +The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) exposes events that allow you to track and respond to user interactions with form fields. The following table summarizes the available events: + +| Event | Description | +|---|---| +| [FormFieldValueChanged](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FormFieldValueChanged) | Raised when the value of a form field changes. | +| [FormFieldFocusChanged](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FormFieldFocusChanged) | Raised when a text or signature field gains or loses focus. | + +To work with form field events in code, ensure the following namespace is imported in your C# file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +{% endhighlight %} +{% endtabs %} + +To use the `SfPdfViewer` control in XAML, add the following namespace declaration to your XAML page: + +{% tabs %} +{% highlight XAML %} +xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" +{% endhighlight %} +{% endtabs %} ## Detect value changes @@ -20,7 +41,7 @@ Subscribe to the event in XAML: {% tabs %} {% highlight XAML %} - {% endhighlight %} {% endtabs %} @@ -28,30 +49,30 @@ Subscribe to the event in XAML: Handle the event in code: {% tabs %} -{% highlight C# %} -private void PdfViewer_FormFieldValueChanged(object? sender, FormFieldValueChangedEventArgs? e) +{% highlight c# %} +private void PdfViewer_FormFieldValueChanged(object sender, FormFieldValueChangedEventArgs e) { - if (e != null && e.FormField is TextFormField textFormField) + if (e.FormField is TextFormField textFormField) { // Read the previous and current values. - string? oldText = e.OldValue?.ToString(); - string? newText = e.NewValue?.ToString(); + string oldText = e.OldValue?.ToString(); + string newText = e.NewValue?.ToString(); } } {% endhighlight %} {% endtabs %} -N> The `OldValue` and `NewValue` types vary by field type. For a checkbox, cast them to `bool` to read the checked state. For a combo box or radio button, cast them to `string`. +**Note:** The `OldValue` and `NewValue` types vary by field type. For a checkbox, cast them to `bool` to read the checked state. For a combo box or radio button, cast them to `string`. -## Detect focus and unfocus +## Detect focus changes -The [FormFieldFocusChanged](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FormFieldFocusChanged) event is raised when a text or signature field gains or loses focus. Use the `HasFocus` property to determine whether the field is being focused or unfocused. +The [FormFieldFocusChanged](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FormFieldFocusChanged) event is raised when a text or signature field gains or loses focus. This event is raised only for text and signature form fields. Use the [HasFocus](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.FormFieldFocusChangedEventArgs.html#Syncfusion_Maui_PdfViewer_FormFieldFocusChangedEventArgs_HasFocus) property of the [FormFieldFocusChangedEventArgs](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.FormFieldFocusChangedEventArgs.html) to determine whether the field is being focused or unfocused. Subscribe to the event in XAML: {% tabs %} {% highlight XAML %} - {% endhighlight %} {% endtabs %} @@ -59,22 +80,21 @@ Subscribe to the event in XAML: Handle the event in code: {% tabs %} -{% highlight C# %} -private void PdfViewer_FormFieldFocusChanged(object? sender, FormFieldFocusChangedEvenArgs? e) +{% highlight c# %} +private void PdfViewer_FormFieldFocusChanged(object sender, FormFieldFocusChangedEventArgs e) { - if (e != null) - { - FormField? field = e.FormField; - bool hasFocus = e.HasFocus; - } + FormField field = e.FormField; + bool hasFocus = e.HasFocus; } {% endhighlight %} {% endtabs %} -N> `FormFieldFocusChanged` is raised only for text and signature form fields. - ## See Also + - [Form Filling Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-overview) - [Edit Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-edit) -- [Form Data Validation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-validation) +- [Form Filling Validation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-validation) - [Form Fields Collection](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-collection) +- [Show and Hide Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-show-hide) +- [Customize Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-customization) +- [Import and Export Form Data](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-import-export) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Import-Export.md b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Import-Export.md index a237239651..d0baac1db6 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Import-Export.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Import-Export.md @@ -12,6 +12,18 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to import form data into a PDF document and export filled form data from it. This is useful for pre-populating forms, backing up responses, or transferring data between systems. +To work with form data import and export in code, ensure the following namespaces are imported in your C# file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +using Syncfusion.Pdf.Parsing; +using System.IO; +{% endhighlight %} +{% endtabs %} + +The `DataFormat` enumeration used for import and export is part of the `Syncfusion.Pdf.NET` package. Ensure this package is installed alongside `Syncfusion.Maui.PdfViewer`. + ## Supported data formats The following formats are supported for both import and export: @@ -20,12 +32,12 @@ The following formats are supported for both import and export: |---|---| | XFDF | XML Forms Data Format — standard format compatible with most PDF viewers. | | FDF | Forms Data Format — standard format compatible with most PDF viewers. | -| JSON | Custom format, compatible with PDF Viewers (WPF, Flutter, JavaScript, etc.). | -| XML | Custom format, compatible with PDF Viewers (WPF, Flutter, JavaScript, etc.). | +| JSON | Syncfusion-specific format for structured form data exchange across Syncfusion PDF viewers (WPF, Flutter, JavaScript, etc.). | +| XML | Syncfusion-specific format for hierarchical form data exchange across Syncfusion PDF viewers (WPF, Flutter, JavaScript, etc.). | -The required format can be selected from the [DataFormat](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Parsing.DataFormat.html) enumeration. +The required format can be selected from the [DataFormat](https://help.syncfusion.com/cr/maui/Syncfusion.Pdf.Parsing.DataFormat.html) enumeration. -N> XFDF and FDF are standard formats compatible with global PDF viewers. JSON and XML are Syncfusion-specific formats for cross-platform use within Syncfusion products only. +**Note:** XFDF and FDF are standard formats compatible with global PDF viewers. JSON and XML are Syncfusion-specific formats for cross-platform use within Syncfusion products only. ## Import form data @@ -34,14 +46,13 @@ Use the [ImportFormData](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Pdf The following example imports form data from an XFDF file stored in the application's data directory. {% tabs %} -{% highlight C# %} +{% highlight c# %} void ImportFormData() { string fileName = Path.Combine(FileSystem.Current.AppDataDirectory, "FormDataInfo.xfdf"); Stream inputFileStream = File.OpenRead(fileName); - inputFileStream.Position = 0; - pdfViewer.ImportFormData(inputFileStream, Syncfusion.Pdf.Parsing.DataFormat.XFdf); + PdfViewer.ImportFormData(inputFileStream, Syncfusion.Pdf.Parsing.DataFormat.XFdf); } {% endhighlight %} {% endtabs %} @@ -49,8 +60,14 @@ void ImportFormData() To continue importing even if the file contains errors, pass `true` for the `continueImportOnError` parameter. {% tabs %} -{% highlight C# %} -pdfViewer.ImportFormData(inputFileStream, Syncfusion.Pdf.Parsing.DataFormat.XFdf, true); +{% highlight c# %} +void ImportFormDataWithOnError() +{ + string fileName = Path.Combine(FileSystem.Current.AppDataDirectory, "FormDataInfo.xfdf"); + Stream inputFileStream = File.OpenRead(fileName); + + PdfViewer.ImportFormData(inputFileStream, Syncfusion.Pdf.Parsing.DataFormat.XFdf, true); +} {% endhighlight %} {% endtabs %} @@ -58,32 +75,42 @@ pdfViewer.ImportFormData(inputFileStream, Syncfusion.Pdf.Parsing.DataFormat.XFdf Use the [ExportFormData](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ExportFormData_System_IO_Stream_Syncfusion_Pdf_Parsing_DataFormat_) method to write the current form field values to a file. Pass an empty writable stream and the desired format. -The following example exports form data to an XFDF file in the application's data directory. +The following example exports form data to an XFDF file in the application's data directory. Ensure the PDF document is loaded before exporting — call `ExportFormData` from the [DocumentLoaded](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoaded) event handler. + +First, wire the `DocumentLoaded` event after loading the document: {% tabs %} -{% highlight C# %} +{% highlight c# %} +// Load the PDF document and add the viewer to the visual tree. +PdfViewer.LoadDocumentAsync(PdfStream); +myGrid.Children.Add(PdfViewer); + +// Subscribe to the DocumentLoaded event to export once the document is fully loaded. +PdfViewer.DocumentLoaded += PdfViewer_DocumentLoaded; +{% endhighlight %} +{% endtabs %} -SfPdfViewer PdfViewer = new SfPdfViewer(); - PdfViewer.LoadDocumentAsync(PdfStream); +Then, handle the event and export the form data: -// Add the SfPdfViewer instance to the grid's children collection to ensure it's part of the visual tree. - myGrid.Children.Add(PdfViewer); - -// Subscribe to the DocumentLoaded event to handle operations once the PDF document is fully loaded. - PdfViewer.DocumentLoaded += PdfViewer_DocumentLoaded; -private void PdfViewer_DocumentLoaded(object? sender, EventArgs? e) +{% tabs %} +{% highlight c# %} +private void PdfViewer_DocumentLoaded(object sender, EventArgs e) { - using (var fileStream = File.Create("D://SavedForm.json")) + string fileName = Path.Combine(FileSystem.Current.AppDataDirectory, "SavedForm.xfdf"); + using (var fileStream = File.Create(fileName)) { - if(sender is SfPdfViewer pdfViewer) - pdfViewer.ExportFormData(fileStream, Syncfusion.Pdf.Parsing.DataFormat.Json); + PdfViewer.ExportFormData(fileStream, Syncfusion.Pdf.Parsing.DataFormat.XFdf); } } {% endhighlight %} {% endtabs %} ## See Also + - [Form Filling Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-overview) -- [Form Data Validation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-validation) +- [Form Filling Validation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-validation) - [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document) - [Import and Export Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/import-export-annotations) +- [Form Fields Collection](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-collection) +- [Edit Form Fields](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-edit) +- [Form Field Events](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-events) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Overview.md b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Overview.md index 66daff411d..3519b2abef 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Overview.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Form-Filling-Overview.md @@ -10,9 +10,17 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne # Form Filling in .NET MAUI PDF Viewer (SfPdfViewer) -The .NET MAUI PDF Viewer [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) enables users to view and fill AcroForm-based PDF forms across mobile and desktop apps. It supports interactive form filling through the built-in UI, and developers can access and modify form data programmatically using the [FormFields](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FormFields) API. +The .NET MAUI PDF Viewer [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) enables users to view and fill AcroForm-based PDF forms across mobile and desktop apps. It supports interactive form filling through the built-in UI, and developers can access and modify form data programmatically using the [FormFields](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FormFields) API. -The viewer supports saving filled forms, flattening form fields to make them non-editable, and importing or exporting form data in FDF, XFDF, JSON, and XML formats. These capabilities make the viewer ideal for capturing and handling form data efficiently within your application. +The viewer supports saving filled forms, flattening form fields to make them non-editable, and importing or exporting form data in FDF, XFDF, JSON, and XML formats. These capabilities make the viewer ideal for capturing and handling form data efficiently within your application. For saving filled forms, see [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document). + +To work with form fields in code, ensure the following namespace is imported in your C# file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +{% endhighlight %} +{% endtabs %} ## Supported form field types @@ -26,12 +34,12 @@ The viewer supports saving filled forms, flattening form fields to make them non | Signature | Captures a handwritten, text, or image signature. | | Button | Renders a button; supports `GoTo` navigation actions only. | -## XFA forms are not supported +## XFA forms -The PDF viewer supports only Acroforms. PDF documents that contain an XFA form cannot be loaded in the PDF Viewer. When a PDF with an XFA form is attempted to be loaded, the [DocumentLoadFailed](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoadFailed) event is raised. +The PDF Viewer supports only AcroForms. PDF documents that contain an XFA form cannot be loaded in the PDF Viewer. When you attempt to load a PDF with an XFA form, the [DocumentLoadFailed](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_DocumentLoadFailed) event is raised. {% tabs %} -{% highlight C# %} +{% highlight c# %} private void PdfViewer_DocumentLoadFailed(object sender, DocumentLoadFailedEventArgs e) { if (e.Message == "This PDF cannot be loaded because it contains XFA form.") diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Free-Text.md b/Document-Processing/PDF/PDF-Viewer/maui/Free-Text.md index f3d1b59dd1..44f53e9a1b 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Free-Text.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Free-Text.md @@ -10,15 +10,24 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne # Free Text Annotations in .NET MAUI PDF Viewer (SfPdfViewer) -The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to add, remove, and modify free text annotation in the PDF document. This is useful for adding text notes, comments, or feedback to the PDF pages. This section will go through the functions available in PDF Viewer for working with free text annotations. +The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to add, remove, and modify free text annotations in the PDF document. This is useful for adding text notes, comments, or feedback to the PDF pages. This section explains the functions available in the PDF Viewer for working with free text annotations. + +To work with free text annotations in code, ensure the following namespaces are imported in your C# file: + +{% tabs %} +{% highlight c# %} +using Syncfusion.Maui.PdfViewer; +using Microsoft.Maui.Graphics; +{% endhighlight %} +{% endtabs %} ## Add free text annotations -This section will go through how to add free text annotations to a PDF page using toolbar as well as programmatically. +This section explains how to add free text annotations to a PDF page using the built-in toolbar as well as programmatically. -### Add the free text annotations using the toolbar +### Add free text annotations using the built-in toolbar -On the built-in toolbar, a free text annotation tool is available. Using that, you can add the free text annotation to the tapped position. Additionally, the toolbar shows the option to modify the properties of existing or new free text annotations. +On the built-in toolbar, a free text annotation tool is available. Using that, you can add the free text annotation to the tapped position. Additionally, the built-in toolbar shows the option to modify the properties of existing or new free text annotations. The following image represents how to add the free text annotations using the toolbar on the desktop. @@ -28,7 +37,7 @@ The following image represents how to add the free text annotation using the too ![Free text Built-in toolbar](Images/mobilefreetext.gif) -### Add free text annotation without using the toolbar +### Add a free text annotation without using the toolbar You can add free text annotation to a PDF document by tapping with a touch (or mouse down) on a PDF page. The following steps explain how to add free text annotation in a PDF. @@ -64,9 +73,9 @@ void DisableFreetextMode() {% endhighlight %} {% endtabs %} -### Adding Annotations Programmatically +### Add annotations programmatically -You can create and add a free Text annotation to a PDF document programmatically using the [AddAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AddAnnotation_Syncfusion_Maui_PdfViewer_Annotation_) method of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following example explains how to create a free text annotation and add it to the first page of a PDF document. +You can create and add a free text annotation to a PDF document programmatically using the [AddAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AddAnnotation_Syncfusion_Maui_PdfViewer_Annotation_) method of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following example explains how to create a free text annotation and add it to the first page of a PDF document. {% tabs %} {% highlight C# %} @@ -124,7 +133,7 @@ void CustomizeDefaultFreeTextSettings() {% endhighlight %} {% endtabs %} -### How to create a free text annotation without a border? +### Create a free text annotation without a border The PDF Viewer allows you to customize annotation properties using the [AnnotationSettings](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.AnnotationSettings.html) property. By default, free text annotations include a visible border. To create a free text annotation without a border, set the [BorderWidth](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.FreeTextAnnotationSettings.html#Syncfusion_Maui_PdfViewer_FreeTextAnnotationSettings_BorderWidth) property to 0 using the [FreeTextAnnotationSettings](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.FreeTextAnnotationSettings.html#properties). @@ -133,7 +142,7 @@ The following example demonstrates how to create a free text annotation without {% tabs %} {% highlight C# %} // Access the default free text annotation settings -FreeTextAnnotationSettings freeTextSettings = pdfViewer.AnnotationSettings.FreeText; +FreeTextAnnotationSettings freeTextSettings = PdfViewer.AnnotationSettings.FreeText; // Set the border width to zero to remove the border freeTextSettings.BorderWidth = 0; @@ -142,6 +151,8 @@ freeTextSettings.BorderWidth = 0; ## Edit the selected free text annotation +You can edit the text content and properties of a selected free text annotation either through UI interaction or programmatically. + ### Edit the text with UI interaction Double-tapping the selected free text annotation will allow you to edit its text content. @@ -187,9 +198,9 @@ The `SfPdfViewer.FreeTextModalViewAppearing` event is triggered whenever the mod {% tabs %} {% highlight c# %} -pdfviewer.FreeTextModalViewAppearing += PdfViewer_FreeTextModalViewAppearing; +PdfViewer.FreeTextModalViewAppearing += PdfViewer_FreeTextModalViewAppearing; -private void PdfViewer_FreeTextModalViewAppearing(object? Sender, AnnotationModalViewAppearingEventArgs e) +private void PdfViewer_FreeTextModalViewAppearing(object? sender, AnnotationModalViewAppearingEventArgs e) { // Implement the logic to hide unwanted UI elements such as toolbar items added to the app UI. } @@ -202,9 +213,9 @@ The `SfPdfViewer.FreeTextModalViewDisappearing` event is triggered when the moda {% tabs %} {% highlight c# %} -pdfviewer.FreeTextModalViewDisappearing += PdfViewer_FreeTextModalViewDisappearing; +PdfViewer.FreeTextModalViewDisappearing += PdfViewer_FreeTextModalViewDisappearing; -Private void PdfViewer_FreeTextModalViewDisappearing(object? Sender, EventArgs e) +private void PdfViewer_FreeTextModalViewDisappearing(object? sender, EventArgs e) { // Implement the logic to show the UI elements that were hidden from the FreeTextModalViewAppearing event handler. } @@ -214,17 +225,17 @@ Private void PdfViewer_FreeTextModalViewDisappearing(object? Sender, EventArgs e ### Suppressing the free text modal view and implementing your own UI -The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to suppress the free text modal view and use your own UI in its place. This can be achieved by setting the [AnnotationModalViewAppearingEventArgs.Cancel](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ModalViewAppearingEventArgs.html#Syncfusion_Maui_PdfViewer_ModalViewAppearingEventArgs_Cancel) property to `true` in the [FreeTextModalViewAppearing](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FreeTextModalViewAppearing) event handler. +The [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to suppress the free text modal view and use your own UI in its place. This can be achieved by setting the [AnnotationModalViewAppearingEventArgs.Cancel](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ModalViewAppearingEventArgs.html#Syncfusion_Maui_PdfViewer_ModalViewAppearingEventArgs_Cancel) property to `true` in the [FreeTextModalViewAppearing](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FreeTextModalViewAppearing) event handler. The `ShowCustomDialog()` and `customDialog.Text` used in the sample below are user-defined and must be implemented by the developer. -The below code snippet illustrates suppressing the free text modal view and using a UI implemented in the app in its place. The free text annotation instance that is created or edited can be obtained from the event args. Once the user enters the text in the custom dialog and confirms, the text can be assigned to this free text annotation instance. +The following code snippet illustrates suppressing the free text modal view and using a UI implemented in the app in its place. The free text annotation instance that is created or edited can be obtained from the event args. Once the user enters the text in the custom dialog and confirms, the text can be assigned to this free text annotation instance. {% tabs %} {% highlight c# %} Annotation editedAnnotation; -pdfviewer.FreeTextModalViewAppearing += PdfViewer_FreeTextModalViewAppearing; +PdfViewer.FreeTextModalViewAppearing += PdfViewer_FreeTextModalViewAppearing; -private void PdfViewer_FreeTextModalViewAppearing(object? Sender, AnnotationModalViewAppearingEventArgs e) +private void PdfViewer_FreeTextModalViewAppearing(object? sender, AnnotationModalViewAppearingEventArgs e) { e.Cancel = true; editedAnnotation = e.Annotation; @@ -232,9 +243,9 @@ private void PdfViewer_FreeTextModalViewAppearing(object? Sender, AnnotationModa ShowCustomDialog(); } -Private void customDialogOkButton_Clicked(object sender, EventArgs e) +private void customDialogOkButton_Clicked(object sender, EventArgs e) { - //Get the typed text from the custom dialog + //Get the typed text from the custom dialog string newText = customDialog.Text; if(editedAnnotation is FreeTextAnnotation freeText) { @@ -245,9 +256,14 @@ Private void customDialogOkButton_Clicked(object sender, EventArgs e) {% endhighlight %} {% endtabs %} -N> For WinUI and MacCatalyst platforms, there is no separate modal view to receive text input from the users. As a result, the [FreeTextModalViewAppearing](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FreeTextModalViewAppearing) and [FreeTextModalViewDisappearing](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FreeTextModalViewDisappearing) events are not applicable for these platforms. +**Note:** For WinUI and MacCatalyst platforms, there is no separate modal view to receive text input from the users. As a result, the [FreeTextModalViewAppearing](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FreeTextModalViewAppearing) and [FreeTextModalViewDisappearing](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_FreeTextModalViewDisappearing) events are not applicable for these platforms. ## See Also + - [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview) -- [Add, Remove, and Modify Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/add-remove-modify-annotations) +- [Add, Remove, and Edit Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/add-remove-modify-annotations) - [Text Markups](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/text-markups) +- [Comments](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-comment) +- [Sticky Notes](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/sticky-notes) +- [Toolbar](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/toolbar) +- [UI Customization](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ui-customization) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Getting-Started.md b/Document-Processing/PDF/PDF-Viewer/maui/Getting-Started.md index 03a061ee29..6adf7cc680 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Getting-Started.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Getting-Started.md @@ -102,7 +102,7 @@ xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Ma using System.ComponentModel; using System.Reflection; -internal class PdfViewerViewModel : INotifyPropertyChanged +public class PdfViewerViewModel : INotifyPropertyChanged { private Stream pdfDocumentStream; @@ -133,7 +133,7 @@ internal class PdfViewerViewModel : INotifyPropertyChanged public PdfViewerViewModel() { // Load the embedded PDF document stream. - // Replace 'PdfViewerExample' with your project's namespace in resource path + // Replace 'PdfViewerExample' with your project's default namespace in the resource path. Verify that the namespace matches your project name. pdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); } @@ -169,8 +169,19 @@ xmlns:local="clr-namespace:PdfViewerExample" {% endhighlight %} {% endtabs %} -N> 1. While changing or opening different documents on the same page, the previously loaded document will be unloaded automatically by the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). -N> 2. If you are using multiple pages in your application, then make sure to unload the document from the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) while leaving the page that has it to release the memory and resources consumed by the PDF document that is loaded. The unloading of documents can be done by calling the [UnloadDocument](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_UnloadDocument) method. +**Note:** 1. While changing or opening different documents on the same page, the previously loaded document will be unloaded automatically by the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). +**Note:** 2. If you are using multiple pages in your application, then make sure to unload the document from the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) while leaving the page that has it to release the memory and resources consumed by the PDF document that is loaded. The unloading of documents can be done by calling the [UnloadDocument](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_UnloadDocument) method. + +{% tabs %} +{% highlight c# %} +// Call UnloadDocument when navigating away from the page to free resources. +protected override void OnNavigatedFrom(NavigatedFromEventArgs args) +{ + PdfViewer.UnloadDocument(); + base.OnNavigatedFrom(args); +} +{% endhighlight %} +{% endtabs %} ## Step 6: Running the Application @@ -187,13 +198,13 @@ Before proceeding, ensure the following are in place: 1. Install [.NET 9 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) or later. 2. Set up a .NET MAUI environment with Visual Studio Code. -3. Ensure that the .NET MAUI workload is installed and configured as described [here](https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?view=net-maui-8.0&tabs=visual-studio-code). +3. Ensure that the .NET MAUI workload is installed and configured as described in the [.NET MAUI installation guide](https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?view=net-maui-9.0&tabs=visual-studio-code). ## Step 1: Create a New MAUI Project -1. Open the command palette by pressing `Ctrl+Shift+P` and type **.NET:New Project** and enter. +1. Open the command palette by pressing `Ctrl+Shift+P` and type **.NET: New Project** and press Enter. 2. Choose the **.NET MAUI App** template. -3. Select the project location, type the project name and press enter. +3. Select the project location, type the project name, and press Enter. 4. Then choose **Create project**. ## Step 2: Install the Syncfusion® MAUI PDF Viewer NuGet Package @@ -265,11 +276,14 @@ xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Ma {% highlight xml tabtitle="PdfViewerExample.csproj" %} - + {% endhighlight %} {% endtabs %} + +If the project does not reload automatically after editing the `.csproj`, close and reopen the project. + 3. In this example, the PDF document is loaded using MVVM binding. Create a new C# file named `PdfViewerViewModel.cs` and add the following code snippet. {% tabs %} @@ -278,7 +292,7 @@ xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Ma using System.ComponentModel; using System.Reflection; -internal class PdfViewerViewModel : INotifyPropertyChanged +public class PdfViewerViewModel : INotifyPropertyChanged { private Stream pdfDocumentStream; @@ -309,7 +323,7 @@ internal class PdfViewerViewModel : INotifyPropertyChanged public PdfViewerViewModel() { // Load the embedded PDF document stream. - // Replace 'PdfViewerExample' with your project's namespace in resource path + // Replace 'PdfViewerExample' with your project's default namespace in the resource path. Verify that the namespace matches your project name. pdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); } @@ -326,7 +340,7 @@ internal class PdfViewerViewModel : INotifyPropertyChanged {% endhighlight %} {% endtabs %} -4. Open the `MainPage.xaml` file again and add the namespace `PdfViewerExample`and name it as `local`. +4. Open the `MainPage.xaml` file again and add the namespace `PdfViewerExample` and name it as `local`. {% tabs %} {% highlight xaml tabtitle="MainPage.xaml" %} xmlns:local="clr-namespace:PdfViewerExample" @@ -368,7 +382,7 @@ Before proceeding, ensure the following are set up: ## Step 1: Create a new .NET MAUI Project -1. Go to **File > New Solution,** Select .NET (C#), and choose the .NET MAUI App template. +1. Go to **File > New Solution**, select .NET (C#), and choose the .NET MAUI App template. 2. Enter the Project Name, Solution Name, and Location. 3. Select the .NET Framework version and click Create. @@ -388,7 +402,7 @@ dotnet restore ## Step 3: Register the Syncfusion® Core Handler -[Syncfusion.Maui.Core](https://www.nuget.org/packages/Syncfusion.Maui.Core/) is a dependency for all MAUI Syncfusion controls. This package will be automatically installed as a dependency when [Syncfusion.Maui.PdfViewer](https://www.nuget.org/packages/Syncfusion.Maui.PdfViewer) NuGet is installed. +[Syncfusion.Maui.Core](https://www.nuget.org/packages/Syncfusion.Maui.Core/) is automatically installed as a dependency when [Syncfusion.Maui.PdfViewer](https://www.nuget.org/packages/Syncfusion.Maui.PdfViewer) NuGet is installed. 1. Add the following namespace in your `MauiProgram.cs` file. {% tabs %} @@ -425,16 +439,16 @@ Open the `MainPage.xaml` file and follow the steps below. 1. Add the following namespace in your MainPage.xaml file. {% tabs %} {% highlight xaml tabtitle="MainPage.xaml" %} - xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" +xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer" {% endhighlight %} {% endtabs %} -2. Add the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) control. Name the PDF viewer control as `pdfViewer`. +2. Add the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) control. {% tabs %} {% highlight xaml tabtitle="MainPage.xaml" %} - + {% endhighlight %} {% endtabs %} @@ -448,7 +462,7 @@ Open the `MainPage.xaml` file and follow the steps below. {% highlight xml tabtitle="PdfViewerExample.csproj" %} - + {% endhighlight %} @@ -461,7 +475,7 @@ Open the `MainPage.xaml` file and follow the steps below. using System.ComponentModel; using System.Reflection; -internal class PdfViewerViewModel : INotifyPropertyChanged +public class PdfViewerViewModel : INotifyPropertyChanged { private Stream pdfDocumentStream; @@ -492,7 +506,7 @@ internal class PdfViewerViewModel : INotifyPropertyChanged public PdfViewerViewModel() { // Load the embedded PDF document stream. - // Replace 'PdfViewerExample' with your project's namespace in resource path + // Replace 'PdfViewerExample' with your project's default namespace in the resource path. Verify that the namespace matches your project name. pdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfViewerExample.Assets.PDF_Succinctly.pdf"); } @@ -539,7 +553,7 @@ N> 2. If you are using multiple pages in your application, then make sure to unl {% endtabcontent %} {% endtabcontents %} -![Getting started with .NET MAUI PDF Viewer](Images\Getting-Started\maui-pdf-viewer-getting-started.png) +![Getting started with .NET MAUI PDF Viewer](Images/Getting-Started/maui-pdf-viewer-getting-started.png) The **Getting Started** example project for the .NET MAUI PDF Viewer can be downloaded [here](https://github.com/SyncfusionExamples/maui-pdf-viewer-examples/tree/master/Getting%20Started).  diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Magnification.md b/Document-Processing/PDF/PDF-Viewer/maui/Magnification.md index dc4d5b61be..2bcdd3c2a0 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Magnification.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Magnification.md @@ -12,7 +12,7 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne Give users precise control over how PDF content is displayed — from pinch-to-zoom on touch screens to setting an exact zoom percentage in code. You can also lock the view to predefined zoom modes like *Fit to Page* or *Fit to Width* to optimize readability for different document types. -## Adjusting the Zoom Factor +## Adjusting the zoom factor You can control the zoom level using the [ZoomFactor](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ZoomFactor) property. Refer to the following code example. @@ -28,7 +28,13 @@ PdfViewer.ZoomFactor = 3; You can also retrieve the current zoom level using the same property. -### Setting Minimum and Maximum Zoom Limits +{% tabs %} +{% highlight c# %} +double currentZoom = PdfViewer.ZoomFactor; +{% endhighlight %} +{% endtabs %} + +### Setting minimum and maximum zoom limits By default, the zoom range varies by platform: * **Mobile (Android/iOS):** 1.0 to 4.0 @@ -63,25 +69,25 @@ The PDF Viewer supports the following zoom modes via the [ZoomMode](https://help The default value is [ZoomMode.Default](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#Syncfusion_Maui_PdfViewer_ZoomMode_Default). -### Zoom Mode via Built-In Toolbar +### Zoom mode via the built-in toolbar #### Desktop Toolbar The built-in toolbar includes a magnification dropdown showing the current zoom percentage. Users can select predefined zoom levels or choose **Fit to Page** / **Fit to Width**. -![Desktop Zoom Mode Combo Box](Images/windowszoom.gif) +![Desktop zoom mode combo box](Images/windowszoom.gif) #### Mobile Toolbar On mobile, the magnification tool appears only after the zoom factor changes. Users can then select **Fit to Page** or **Fit to Width**. Once selected, the icon disappears until the zoom factor changes again. -![Mobile Zoom Mode Combo box](Images/ZoomModeforMobile.gif) +![Mobile zoom mode combo box](Images/ZoomModeforMobile.gif) -### Programmatically Setting Zoom Mode +### Programmatically setting zoom mode #### Fit to Page -You can change the [SfPdfViewer.ZoomMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#fields) using the [ZoomMode.FitToPage](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#Syncfusion_Maui_PdfViewer_ZoomMode_FitToPage) enumeration. It will magnify the PDF document so that the entire PDF page is visible in the view port. +You can change the [SfPdfViewer.ZoomMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#fields) using the [ZoomMode.FitToPage](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#Syncfusion_Maui_PdfViewer_ZoomMode_FitToPage) enumeration. It magnifies the PDF document so that the entire PDF page is visible in the viewport. Refer to the following code example:  {% tabs %} @@ -97,7 +103,7 @@ pdfViewer.ZoomMode = ZoomMode.FitToPage; #### Fit to Width -You can change the [SfPdfViewer.ZoomMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#fields) using the [ZoomMode.FitToWidth](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#Syncfusion_Maui_PdfViewer_ZoomMode_FitToWidth) enumeration. It will magnify the PDF document so that the widest page of the PDF document fits the width of the view port. +You can change the [SfPdfViewer.ZoomMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#fields) using the [ZoomMode.FitToWidth](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.ZoomMode.html#Syncfusion_Maui_PdfViewer_ZoomMode_FitToWidth) enumeration. It magnifies the PDF document so that the widest page of the PDF document fits the width of the viewport. Refer to the following code example: {% tabs %} @@ -106,14 +112,14 @@ Refer to the following code example: {% endhighlight %} {% highlight c# %} -// To apply fit-to-page zoom mode. +// To apply fit-to-width zoom mode. pdfViewer.ZoomMode = ZoomMode.FitToWidth; {% endhighlight %} {% endtabs %} N> When the `ZoomFactor` is manually changed, the `ZoomMode` resets to `Default`. You can reapply the desired zoom mode afterward. -## Maintain Zoom Level in Single Page View Mode +## Maintain zoom level in single-page view mode In single-page view mode, the zoom level resets to default each time you navigate to a new page. To maintain a consistent zoom factor throughout the document, enable the [PersistZoomOnPageChange](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_PersistZoomOnPageChange) property. This applies whether navigation is triggered by the built-in toolbar controls or programmatic APIs. The default value of [PersistZoomOnPageChange](https://help.syncfusion.com/cr/document-processing/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_PersistZoomOnPageChange) is `False`. @@ -153,7 +159,7 @@ PdfViewer.PersistZoomOnPageChange = false; {% endhighlight %} {% endtabs %} -## Enable or Disable Double-Tap Zoom +## Enable or disable double-tap zoom The PDF Viewer allows users to zoom in and out of the document using a double-tap gesture. This behavior can be controlled programmatically using the `AllowDoubleTapZoom` property. @@ -173,6 +179,10 @@ pdfViewer.AllowDoubleTapZoom = false; {% endtabs %} ## See Also + - [Scrolling](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/scrolling) - [Page Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/page-navigation) - [Gesture Events](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/gesture-events) +- [Toolbar](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/toolbar) +- [UI Customization](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ui-customization) +- [Getting Started](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/getting-started) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Overview.md b/Document-Processing/PDF/PDF-Viewer/maui/Overview.md index 4fe084bb75..f8e12c5d87 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Overview.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Overview.md @@ -10,13 +10,13 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne # .NET MAUI PDF Viewer (SfPdfViewer) Overview -Build powerful PDF experiences into your .NET MAUI app with the [SfPdfViewer](https://www.syncfusion.com/maui-controls/maui-pdf-viewer) control. Whether you need to display documents for review, let users fill out forms, redact sensitive data, or annotate content — the PDF Viewer gives you a full-featured, cross-platform solution that works on Android, iOS, macOS, and Windows from a single code base. +Build powerful PDF experiences into your .NET MAUI app with the [SfPdfViewer](https://www.syncfusion.com/maui-controls/maui-pdf-viewer) control. Whether you need to display documents for review, let users fill out forms, redact sensitive data, or annotate content — the PDF Viewer gives you a full-featured, cross-platform solution that works on Android, iOS, macOS, and Windows from a single codebase. To get started, see [Getting Started](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/getting-started). -## In This Section +## In this section | Topic | Description | |---|---| -| [Getting Started](https://help.syncfusion.com/maui/pdf-viewer/getting-started) | Install the package, configure the handler, and load your first PDF document. | +| [Getting Started](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/getting-started) | Install the package, configure the handler, and load your first PDF document. | | [Open a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/open-a-document) | Load documents from streams, local storage, URLs, Base64 strings, or password-protected files. | | [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview) | Add, edit, import, and export highlights, shapes, ink, stamps, sticky notes, and more. | | [Form Filling Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-overview) | Fill, edit, import, and export PDF form fields including text boxes, checkboxes, and signatures. | @@ -26,42 +26,68 @@ Build powerful PDF experiences into your .NET MAUI app with the [SfPdfViewer](ht | [Toolbar Customization](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/toolbar-customization) | Show, hide, add, remove, and reorder toolbar items. | | [UI Customization](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ui-customization) | Customize the appearance of the PDF Viewer control. | | [Redaction](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/redaction) | Permanently remove sensitive content from PDF documents. | -| [Electronic Signature](https://help.syncfusion.com/maui/pdf-viewer/signature) | Add handwritten, typed, or image-based signatures. | -| [Keyboard Shortcuts](https://help.syncfusion.com/maui/pdf-viewer/keyboard-shortcuts) | Keyboard shortcuts available on desktop platforms. | -| [Localization](https://help.syncfusion.com/maui/pdf-viewer/localization) | Translate all built-in strings into any supported language. | +| [Electronic Signature](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/signature) | Add handwritten, typed, or image-based signatures. | +| [Keyboard Shortcuts](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/keyboard-shortcuts) | Keyboard shortcuts available on desktop platforms. | +| [Localization](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/localization) | Translate all built-in strings into any supported language. | | [Migration Guide](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/migration) | Migrate from Xamarin.Forms SfPdfViewer to .NET MAUI SfPdfViewer. | ## Key Features +### Navigation and viewing + * **Virtual scrolling** - Easily scroll through the pages in the document fluently. Pages are rendered only when required to improve loading and scrolling performance. * **Magnification** - The content of a PDF document can be efficiently zoomed in and out by pinching or changing the zoom factor programmatically. * **Zoom modes** - Improve document readability by adjusting magnification to suit your viewing needs. Use *Fit to Page* to display the entire page without scrolling, ideal for quick overviews. Choose *Fit to Width* for optimal reading of content with narrow columns, such as newspapers or multi-column layouts. * **Page navigation** - Navigate to the desired pages instantly using the page navigation option programmatically or by dragging the scroll head in the UI. -* **Open password-protected PDFs** - Load and view password-protected PDFs in a hassle-free way. You can design a custom password request view and integrate the functionality easily with the options available. -* **Built-in Toolbar** - The PDF Viewer control includes a built-in toolbar, offering a seamless user experience with essential functions such as page navigation, text search, page layout mode adjustments, and various annotation tools. The toolbar's visibility can also be customized according to user preferences. -* **Text search** - Search for text and instantly navigate all its occurrences in a PDF document. -* **Select and copy text** - Select text from a PDF document and copy it to the clipboard. This helps share text content with others. +* **Page layout modes** - View the PDF files in different page layout modes, such as continuous scroll and single page. * **Outline view** - Use the outline view's hierarchical list of headings and subheadings to instantly navigate to the required topic in the document. * **Custom bookmarks** - Add, remove, and modify custom bookmarks in PDF files. This feature lets you quickly jump to specific sections or chapters without scrolling through the entire document. * **Document link navigation** - Navigate to the topic or position by tapping the document link annotation of the topics in the table of contents in a PDF document. * **Hyperlink navigation** - Detects hyperlinks, and tapping on the hyperlink will open the URL in a browser. -* **Form filling** - Fill, modify, import, export, and save form data from PDF documents. This feature helps to digitize the manual process of filling out paper forms. This can be used for filling out job applications, registration forms, medical forms, etc. Supported form fields are text box, checkbox, radio button, combo box, list box, button (only GoTo actions), and signature. -* **Ink or free-hand drawing annotation** - Add, remove, modify, save, import, and export ink annotations in PDF files. This feature will help make quick notes on specific text or passages, add marks or drawings to images, and add handwritten signatures. -* **Ink or free-hand drawing eraser** - Remove or erase portions of freehand drawings or ink annotations. This feature can be used to correct a mistake or remove unwanted marks. -* **Shape annotations** - Add, remove, modify, import, and export shape annotations in PDF files. The available shapes are arrow, circle, line, rectangle, polygon, and polyline. This feature will help highlight important paragraphs, images, or blocks of text, point out certain areas of interest, underline text or phrases in an image, or divide different sections or paragraphs, and provide directional guidance. +* **Text search** - Search for text and instantly navigate all its occurrences in a PDF document. +* **Select and copy text** - Select text from a PDF document and copy it to the clipboard. This helps share text content with others. +* **Coordinates conversion** - Obtain the PDF page coordinates relative to the PDF Viewer's client coordinates and vice versa. It also helps to obtain the scroll point relative to the PDF page coordinates and bring the given region into view. + +### Document loading and security + +* **Open password-protected PDFs** - Load and view password-protected PDFs in a hassle-free way. You can design a custom password request view and integrate the functionality easily with the options available. +* **Redaction** - Permanently remove sensitive content from PDF documents. + +### Annotations + +* **Ink or freehand drawing annotation** - Add, remove, modify, save, import, and export ink annotations in PDF files. This feature helps make quick notes on specific text or passages, add marks or drawings to images, and add handwritten signatures. +* **Ink or freehand drawing eraser** - Remove or erase portions of freehand drawings or ink annotations. This feature can be used to correct a mistake or remove unwanted marks. +* **Shape annotations** - Add, remove, modify, import, and export shape annotations in PDF files. The available shapes are arrow, circle, line, rectangle, polygon, and polyline. This feature helps highlight important paragraphs, images, or blocks of text, point out certain areas of interest, underline text or phrases in an image, or divide different sections or paragraphs, and provide directional guidance. * **Stamp annotation** - Add, remove, modify, import, and export stamp annotations in PDF files. Stamps are predefined graphical text that can be used to mark or signify certain aspects of documents, like that they have undergone quality checks or audits. This feature also allows adding personalized images or text to PDF documents. -* **Sticky note annotation** - Add, remove, modify, import, and export sticky note annotations in PDF files. This feature will help add comments or notes to a specific part of a document to clarify complex concepts, terms, or ideas. -* **Text markup annotations** - Add, remove, modify, import, and export text markup annotations in PDF files. The available text markups are highlight, underline, strikeout, and squiggly. This feature will help mark important passages, emphasize specific words or phrases, indicate that certain content should be removed, or indicate that text contains possible errors. +* **Sticky note annotation** - Add, remove, modify, import, and export sticky note annotations in PDF files. This feature helps add comments or notes to a specific part of a document to clarify complex concepts, terms, or ideas. +* **Text markup annotations** - Add, remove, modify, import, and export text markup annotations in PDF files. The available text markups are highlight, underline, strikeout, and squiggly. This feature helps mark important passages, emphasize specific words or phrases, indicate that certain content should be removed, or indicate that text contains possible errors. * **Free text annotation** - Add, remove, modify, import, and export free text annotations in PDF files. This feature helps to add text notes, comments, or feedback to PDF documents. -* **Show and Hide Annotations** - This feature enables users to manage the visibility of specific annotations or all annotations within the document. +* **Show and hide annotations** - This feature enables users to manage the visibility of specific annotations or all annotations within the document. + +### Form filling and signatures + +* **Form filling** - Fill, modify, import, export, and save form data from PDF documents. This feature helps to digitize the manual process of filling out paper forms. This can be used for filling out job applications, registration forms, medical forms, etc. Supported form fields are text box, checkbox, radio button, combo box, list box, button (only GoTo actions), and signature. * **Electronic signatures** - Add, remove, and modify electronic signatures in PDF files that include freehand-drawn, text, and image signatures. It can be used to sign contracts and agreements digitally, eliminating the need for physical signatures. -* **Page layout modes** - View the PDF files in different page layout modes, such as continuous scroll and single page. -* **Save** - Save the modified PDF files. -* **Print** - Print the PDF files. -* **Coordinates conversion** - Obtain the PDF page coordinates relative to the PDF Viewer’s client coordinates and vice versa. It also helps to obtain the scroll point relative to the PDF page coordinates and bring the given region into view. + +### Toolbar and customization + +* **Built-in toolbar** - The PDF Viewer control includes a built-in toolbar, offering a seamless user experience with essential functions such as page navigation, text search, page layout mode adjustments, and various annotation tools. The toolbar's visibility can also be customized according to user preferences. * **Localization** - All static text within the PDF Viewer can be localized to any supported language. +### Saving and printing + +* **Save** - Save the modified PDF files to a file stream, with optional annotation flattening. +* **Print** - Print the PDF files directly from the viewer. + ## See Also + - [Getting Started](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/getting-started) +- [Open a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/open-a-document) - [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview) - [Form Filling Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/form-filling-overview) +- [Page Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/page-navigation) +- [Magnification](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/magnification) +- [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document) +- [Print a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/print-a-document) +- [Toolbar](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/toolbar) +- [Redaction](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/redaction) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Redaction.md b/Document-Processing/PDF/PDF-Viewer/maui/Redaction.md index c3fb16a8c0..6ebe255cdd 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Redaction.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Redaction.md @@ -12,22 +12,38 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne Before sharing a PDF externally, use redaction to permanently remove sensitive data — such as personal details, financial figures, or confidential text — from the document. Unlike simply covering content with a shape or annotation, redaction in [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) eliminates the underlying content entirely once the document is saved, making recovery impossible. -## Types of Redactions +## Types of redactions The PDF Viewer provides multiple methods to apply redaction, allowing you to securely conceal sensitive content based on different requirements. The available redaction types include: -- **Text-based Redaction** : Allows you to manually select the texts on a page and apply redaction to hide the texts. -- **Selected Area Redaction** : Allows you to manually select a rectangular area on a page and apply redaction to hide any content within that region. -- **Page-based Redaction** : Enables you to redact entire pages of a PDF document, ensuring that all content on those pages is permanently removed. +- **Text-based redaction**: Allows you to manually select the texts on a page and apply redaction to hide the texts. +- **Selected area redaction**: Allows you to manually select a rectangular area on a page and apply redaction to hide any content within that region. +- **Page-based redaction**: Enables you to redact entire pages of a PDF document, ensuring that all content on those pages is permanently removed. +Text-based and selected-area redactions can be performed either with the built-in toolbar or with UI interaction using the `RedactionMode` property. Page-based redaction is available only programmatically via the `AddPageRedactionMarks` method. -## Mark region to redact +## Customize the default redaction appearance + +In redaction mode, the redaction is applied with a default appearance and behavior. You can modify these settings before marking regions on the pages. To define the appearance and behavior, customize the default settings using the [RedactionSettings](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactionSettings) property of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). +The following example demonstrates how to obtain the default redaction settings and modify their appearance properties. Similarly, you can modify other available properties. -You need to mark the region for redaction by using one of the available methods such as text-based, selected-area or page-based redaction. +{% tabs %} +{% highlight c# %} +void CustomizeDefaultRedactionSettings() +{ + // Access the default redaction settings from the SfPdfViewer instance and modify the default appearance properties. + PdfViewer.RedactionSettings.MarkerBorderColor = Colors.Blue; // Border color for the marked region. + PdfViewer.RedactionSettings.FillColor = Colors.Red; // Fill color after redaction is applied. + PdfViewer.RedactionSettings.FontColor = Colors.Black; // Font color for overlay text. + PdfViewer.RedactionSettings.OverlayText = "text"; // Text to display on the redacted area. + PdfViewer.RedactionSettings.IsRepeat = true; // Repeat overlay text across the redacted area. +} +{% endhighlight %} +{% endtabs %} -## Mark regions for redaction using toolbar +## Mark regions for redaction using the built-in toolbar -The built-in toolbar includes a redaction tool that allows you to redact text, specific areas, or entire pages by marking the desired region on the PDF document and clicking the Apply button. The toolbar also provides options to modify redaction properties, such as the color and the text to display in the redacted area. +You need to mark the region for redaction by using one of the available methods such as text-based, selected-area, or page-based redaction. The built-in toolbar includes a redaction tool that allows you to redact text, specific areas, or entire pages by marking the desired region on the PDF document and clicking the Apply button. The toolbar also provides options to modify redaction properties, such as the color and the text to display in the redacted area. The following image represents how to perform redactions using the toolbar on the desktop. @@ -39,14 +55,14 @@ The following image represents how to perform redactions using the toolbar on mo ## Mark regions for redaction without using the toolbar -You can mark the region for redaction in a PDF document with UI interaction using touch or mouse using the [RedactionMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactionMode) property in the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following steps explain how to mark the region on a PDF. +You can mark the region for redaction in a PDF document with UI interaction (touch or mouse) by setting the [RedactionMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactionMode) property of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following steps explain how to mark the region on a PDF. -1. Set the [RedactionMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactionMode) property of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) to Text or Rect. It activates the text-based or selected-area Redaction mode on the control. -2. Place your finger (or mouse) on the text in the PDF document, where you want to start redaction. +1. Set the [RedactionMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactionMode) property of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) to Text or Rect. It activates the text-based or selected-area redaction mode on the control. +2. Place your finger (or mouse) over the text in the PDF document where you want to start redaction. 3. Drag the finger (or cursor) across the text to select. 4. Complete adding the region to the selected text or area by releasing the finger (or cursor). -5. Once you have done that, set the [RedactionMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactionMode) to None. It will disable the redaction mode and save the marked region for redaction. -6. You can later redact the marked regions using [RedactAsync](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactAsync_System_Threading_CancellationToken_) method. +5. Once you have finished marking regions, set the [RedactionMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactionMode) to None. It will disable the redaction mode. The marked regions will be retained for redaction. +6. You can later redact the marked regions using the [RedactAsync](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactAsync_System_Threading_CancellationToken_) method. The following code explains how to enable the text-based redaction mode. @@ -83,7 +99,7 @@ void DisableRedactionMode() ## How to perform redaction programmatically -### Add redaction mark on the PDF +### Add a redaction mark to the PDF You can mark regions for text or specific areas programmatically using the [AddRedactionMark](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AddRedactionMark_Syncfusion_Maui_PdfViewer_RedactionMark_) method of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html), and redact entire pages using the [AddPageRedactionMarks](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AddPageRedactionMarks_System_Collections_Generic_List_System_Int32__) method. The following example demonstrates how to mark regions for redaction, such as a specific area and page in the PDF document. @@ -102,17 +118,31 @@ void AddRedactionMarkOnSpecificRegionAndPages() PdfViewer.AddRedactionMark(redactionMark); // Add redaction marks to specific pages (pages 3, 5, and 1). - PdfViewer.AddPageRedactionMarks(new List([3, 5, 1])); + PdfViewer.AddPageRedactionMarks(new List { 3, 5, 1 }); } {% endhighlight %} {% endtabs %} -### Remove the selected redaction mark on the PDF +### Redact the marked region -You can remove a redaction mark for text, a specific area, or a page programmatically using the [SelectedRedactionMark](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_SelectedRedactionMark) property and the [RemoveRedactionMark](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RemoveRedactionMark_Syncfusion_Maui_PdfViewer_RedactionMark_) method of SfPdfViewer. To remove a redaction mark, select the specific mark you want to delete and pass it to the [RemoveRedactionMark](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RemoveRedactionMark_Syncfusion_Maui_PdfViewer_RedactionMark_) method. The following example demonstrates how to remove a selected redaction mark from the PDF document. +After marking the regions, you can redact them by using the [RedactAsync](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactAsync_System_Threading_CancellationToken_) method of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). This method redacts all marked regions and saves the document, making the changes irreversible. The following example demonstrates how to redact a marked region or page in a PDF document. {% tabs %} -{% highlight C# %} +{% highlight c# %} +private async void RedactMarkedRegion() +{ + // Apply redaction to all marked regions in the PDF document. + await PdfViewer.RedactAsync(); +} +{% endhighlight %} +{% endtabs %} + +### Remove the selected redaction mark + +You can remove a redaction mark for text, a specific area, or a page programmatically using the [SelectedRedactionMark](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_SelectedRedactionMark) property and the [RemoveRedactionMark](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RemoveRedactionMark_Syncfusion_Maui_PdfViewer_RedactionMark_) method of the SfPdfViewer. To remove a redaction mark, select the specific mark you want to delete and pass it to the [RemoveRedactionMark](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RemoveRedactionMark_Syncfusion_Maui_PdfViewer_RedactionMark_) method. The following example demonstrates how to remove a selected redaction mark from the PDF document. + +{% tabs %} +{% highlight c# %} void RemoveSelectedRedactionMark() { // Check if any redaction mark is currently selected. @@ -125,12 +155,12 @@ void RemoveSelectedRedactionMark() {% endhighlight %} {% endtabs %} -### Remove all the redaction marks in the PDF +### Remove all redaction marks You can remove all redaction marks from a document programmatically by calling the [RemoveAllRedactionMarks](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RemoveAllRedactionMarks) method. The following example demonstrates how to remove all redaction marks from a PDF document. {% tabs %} -{% highlight C# %} +{% highlight c# %} void RemoveAllRedactionMarksDrawn() { // Removes all the redaction marks from a PDF document using [RemoveAllRedactionMarks](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RemoveAllRedactionMarks) method of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). @@ -139,41 +169,12 @@ void RemoveAllRedactionMarksDrawn() {% endhighlight %} {% endtabs %} -### Redact the marked region - -You can redact the marked regions by using the [RedactAsync](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactAsync_System_Threading_CancellationToken_) method of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). This method redacts all marked regions and saves the document, making the changes irreversible. The following example demonstrates how to redact a marked region or page in a PDF document. - -{% tabs %} -{% highlight C# %} -private async void RedactMarkedRegion() -{ - // Apply redaction to all marked regions in the PDF document. - await PdfViewer.RedactAsync(); -} -{% endhighlight %} -{% endtabs %} - -## Customize the default redaction appearance - -In redaction mode, the redaction is applied with a default appearance and behavior. You can modify these settings before marking regions on the pages. To define the appearance and behavior, customize the default settings using the [RedactionSettings](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RedactionSettings) property of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). -The following example demonstrates how to obtain the default redaction settings and modify their appearance properties. Similarly, you can modify other available properties. - -{% tabs %} -{% highlight C# %} -void CustomizeDefaultRedactionSettings() -{ - // Access the default redaction settings from the SfPdfViewer instance and modify the default appearance properties. - PdfViewer.RedactionSettings.MarkerBorderColor = Colors.Blue; // Border color for the marked region. - PdfViewer.RedactionSettings.FillColor = Colors.Red; // Fill color after redaction is applied. - PdfViewer.RedactionSettings.FontColor = Colors.Black; // Font color for overlay text. - PdfViewer.RedactionSettings.OverlayText = "text"; // Text to display on the redacted area. - PdfViewer.RedactionSettings.IsRepeat = true; // Repeat overlay text across the redacted area. -} -{% endhighlight %} -{% endtabs %} - ## See Also + - [Save a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/save-a-document) - [Text Search](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/text-search) - [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview) - [Undo and Redo](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/undo-redo) +- [Toolbar](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/toolbar) +- [Open a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/open-a-document) +- [Print a Document](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/print-a-document) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Scrolling.md b/Document-Processing/PDF/PDF-Viewer/maui/Scrolling.md index 5468d2d858..038b8348f5 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Scrolling.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Scrolling.md @@ -14,7 +14,7 @@ Keep document navigation smooth and predictable by using the PDF Viewer's built- W> Since the PDF Viewer includes built-in scrolling, avoid placing it inside other scrollable containers like [ScrollView](https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/scrollview?view=net-maui-8.0), as this may lead to unexpected behavior. -## Programmatic Scrolling +## Programmatic scrolling Use the [ScrollToOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ScrollToOffset_System_Double_System_Double_) method to scroll to a specific horizontal and vertical offset. Offset values are measured in **device-independent units**. If the specified offset is invalid or out of bounds, the scroll action will be ignored and the viewer will retain its current position. @@ -25,11 +25,11 @@ PdfViewer.ScrollToOffset(100, 1000); {% endhighlight %} {% endtabs %} -## Detect Scroll Changes +## Detect scroll changes -You can monitor scroll changes using the `PropertyChanged` event. By monitoring the [HorizontalOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_HorizontalOffset) and [VerticalOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_VerticalOffset) property changes, you can respond to both the horizontal and vertical scroll movements respectively. +You can monitor scroll changes using the `PropertyChanged` event. By monitoring the [HorizontalOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_HorizontalOffset) and [VerticalOffset](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_VerticalOffset) property changes, you can respond to horizontal and vertical scroll movements. -The following is the code example for subscribing to the `PropertyChanged` event. +The following code example shows how to subscribe to the `PropertyChanged` event. {% tabs %} {% highlight XAML %} @@ -50,7 +50,7 @@ void SubscribeToPropertyChangedEvent() {% endhighlight %} {% endtabs %} -The following code example illustrates how implement the event handler and to respond to both horizontal and vertical scroll changes: +The following code example illustrates how to implement the event handler and respond to both horizontal and vertical scroll changes: {% tabs %} {% highlight c# %} @@ -71,15 +71,15 @@ private void PdfViewer_PropertyChanged(object sender, {% endhighlight %} {% endtabs %} -## Detecting End of Document +## Detecting end of document You can determine if the control has reached the vertical end of the document by evaluating the following properties: -* `VerticalOffset`: It provides the current vertically scrolled offset. -* `ClientRectangle`: It provides the viewport area bounds. -* `ExtentHeight`: It provides the overall vertical height of the PDF document. +* `VerticalOffset`: Provides the current vertical scroll offset. +* `ClientRectangle`: Provides the viewport area bounds. +* `ExtentHeight`: Provides the overall vertical height of the PDF document. -Below is the code example to detect whether the control has reached the vertical end of the document. +The following code example detects whether the control has reached the vertical end of the document. {% tabs %} {% highlight c# %} @@ -110,7 +110,6 @@ private void PdfViewer_PropertyChanged(object sender, PdfViewer.ClientRectangle.Width >= PdfViewer.ExtentWidth); } } - {% endhighlight %} {% endtabs %} @@ -118,7 +117,7 @@ private void PdfViewer_PropertyChanged(object sender, On Android and iOS platforms, the scroll head offers a quick way to move through pages. Users can drag the thumb indicator to scroll within the PDF document. -![Scroll Head](Images\ScrollHead.png) +![Scroll head](Images/ScrollHead.png) ### Show or Hide the Scroll Head @@ -139,7 +138,7 @@ When scrolling through large PDF documents, you may notice blank pages appearing To minimize this and provide a smoother scrolling experience, the SfPdfViewer control offers the `OverscanCount` property. This property defines how many pages should be pre-rendered and kept in memory on each side of the current viewport. Increasing this value reduces the chance of blank pages during fast scrolling but may increase memory usage. -The following example shows how to set `OverscanCount` property: +The following example shows how to set the `OverscanCount` property: {% tabs %} {% highlight xaml %} @@ -148,20 +147,21 @@ The following example shows how to set `OverscanCount` property: {% endhighlight %} {% highlight c# %} -SfPdfViewer PdfViewer = new SfPdfViewer(); - // Set the cache range (number of pages before and after the current viewport) PdfViewer.OverscanCount = 15; - -// Load a PDF document -PdfViewer.LoadDocument("sample.pdf"); {% endhighlight %} {% endtabs %} -N> - Use a reasonable OverscanCount value. Large values can cause memory spikes and app freezes. -N> - Pages with very high resolution may still render slowly due to native rendering limitations. +**Note:** +* Use a reasonable `OverscanCount` value. Large values can cause memory spikes and app freezes. +* Pages with very high resolution may still render slowly due to native rendering limitations. ## See Also + - [Page Navigation](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/page-navigation) - [Magnification](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/magnification) - [Gesture Events](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/gesture-events) +- [Toolbar](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/toolbar) +- [UI Customization](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ui-customization) +- [Getting Started](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/getting-started) +- [Coordinate Conversion](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/coordinates-conversion) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Shapes.md b/Document-Processing/PDF/PDF-Viewer/maui/Shapes.md index a43874cbac..39557b0c21 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Shapes.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Shapes.md @@ -10,24 +10,24 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, mau # Shape Annotations in .NET MAUI PDF Viewer (SfPdfViewer) -The shape annotations feature of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to add, remove and modify shapes in the PDF document. This is useful for making corrections or emphasizing important points in the document. This section will go through the various types and functions available in the PDF Viewer for working with shape annotations. +The shape annotations feature of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to add, remove, and modify shapes in the PDF document. This is useful for making corrections or emphasizing important points in the document. This section explains the various types and functions available in the PDF Viewer for working with shape annotations. ## Types of shapes -The following shape annotation types are now available in the PDF Viewer. +The following shape annotation types are available in the PDF Viewer. -1. Arrow -2. Circle. -3. Line. -4. Square. -5. Polygon. -6. Polyline. +1. Arrow +2. Circle +3. Line +4. Square +5. Polygon +6. Polyline ## Add shapes to a PDF document -This section will cover how to add shape annotations to a PDF document using a toolbar as well as programmatically. +This section explains how to add shape annotations to a PDF document using the built-in toolbar as well as programmatically. -### Add shapes using the toolbar +### Add shapes using the toolbar A shape annotation tool with seven different sorts of annotations (arrow, circle, square, line, polygon, polyline, and cloud) is accessible on the built-in toolbar. Users are able to select any of these shapes and draw them on the page at any desired location. Additionally, the toolbar allows modification of properties for both existing and new annotations of the selected shape. @@ -51,9 +51,9 @@ You can interactively draw and add shape annotations to a PDF document by touch 6. Once you have done this, set the [AnnotationMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationMode) to [None](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.AnnotationMode.html#Syncfusion_Maui_PdfViewer_AnnotationMode_None). This will disable the circle drawing mode and save the drawn circles to the PDF pages as circle annotations. 7. You can later move, resize, or edit the annotation. -### Add Polygon and Polyline shapes +### Add polygon and polyline shapes -Adding polygon and polyline shapes with touch or mouse will vary slightly from adding other shape types. To add it interactively, refer to the following steps. +Adding polygon and polyline shapes with a touch or mouse differs slightly from adding other shape types. To add one interactively, refer to the following steps. 1. Set the [AnnotationMode](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationMode) property of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) to [Polygon](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.AnnotationMode.html#Syncfusion_Maui_PdfViewer_AnnotationMode_Polygon) or [Polyline](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.AnnotationMode.html#Syncfusion_Maui_PdfViewer_AnnotationMode_Polyline). It sets the control’s drawing mode to polygon or polyline, respectively. 2. To begin drawing the shape, tap the desired location on the screen (using touch or mouse). @@ -118,7 +118,7 @@ CircleAnnotation CreateCircleAnnoation() void AddCircleAnnotation() { - Annotation circleAnnotation = CreateCircleAnnoation(); + Annotation circleAnnotation = CreateCircleAnnotation(); //Add the circle annotation to the PDF document using the AddAnnotation method of the `SfPdfViewer` instance. PdfViewer.AddAnnotation(circleAnnotation); @@ -133,7 +133,7 @@ In the shape annotation mode, the shape annotations will be drawn with a default The following example explains how to obtain the default circle annotation settings and modify some of its properties. Similarly, you can also modify the properties of other shape annotations. {% tabs %} -{% highlight C# %} +{% highlight c# %} void CustomizeDefaultCircleSettings() { //Obtain the default circle annotation settings from the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) instance. @@ -151,7 +151,7 @@ void CustomizeDefaultCircleSettings() ## Edit the selected shape annotation -You can edit the properties of the selected shape annotation programmatically by accessing the selected annotation instance. The selected annotation instance may be obtained from the [AnnotationSelected](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationSelected) event. The following example shows how to edit some of the properties of the selected circle annotation. Similarly, you can modify the other shape annotation properties. +You can edit the properties of the selected shape annotation programmatically by accessing the selected annotation instance. You can obtain the selected annotation instance from the [AnnotationSelected](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationSelected) event. The following example shows how to edit some of the properties of the selected circle annotation. Similarly, you can modify the other shape annotation properties. {% tabs %} {% highlight C# %} @@ -159,7 +159,7 @@ You can edit the properties of the selected shape annotation programmatically by /// Edit the selected circle annotation. /// /// The selected annotation instance that may be obtained from the annotation selected event -void EditSelectedCicleAnnotation(Annotation selectedAnnotation) +void EditSelectedCircleAnnotation(Annotation selectedAnnotation) { // Typecast the selected annotation as a circle annotation. if (selectedAnnotation is CircleAnnotation circleAnnotation) @@ -175,42 +175,41 @@ void EditSelectedCicleAnnotation(Annotation selectedAnnotation) ## Border styles for shape annotation [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to change the shape annotations' border style. Currently, it provides support for the following border styles. -1. Cloudy -2. Solid +1. Cloudy +2. Solid N> By default, the border style of the shape annotations is solid. The value of `BorderStyle` property is applicable only for square and polygon annotations only and it does not affect other shape annotations such as circle, line, arrow, and polyline annotations. -### Draw cloud shaped annotation +### Draw a cloud-shaped annotation -To draw a cloud annotation, set the annotation mode to either [AnnotationMode.Square](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.AnnotationMode.html) or [AnnotationMode.Polygon](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.AnnotationMode.html). Then you should set the `BorderStyle` property of the shape annotation settings to `BorderStyle.Cloudy`. The following sample code illustrates how to draw a rectangle and polygon annotation with the cloud border style. +To draw a cloud annotation, set the annotation mode to either [AnnotationMode.Square](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.AnnotationMode.html) or [AnnotationMode.Polygon](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.AnnotationMode.html). Then you should set the `BorderStyle` property of the shape annotation settings to `BorderStyle.Cloudy`. The following sample code illustrates how to draw a square and polygon annotation with the cloud border style. {% tabs %} -{% highlight C# %} +{% highlight c# %} // Draw square cloud annotation - SfPdfViewer pdfViewer = new SfPdfViwer(); - pdfViewer.AnnotationMode = AnnotationMode.Square; - pdfViewer.AnnotationSettings.Rectangle.BorederStyle = BorderStyle.Cloudy; + PdfViewer.AnnotationMode = AnnotationMode.Square; + PdfViewer.AnnotationSettings.Rectangle.BorderStyle = BorderStyle.Cloudy; {% endhighlight %} {% endtabs %} {% tabs %} -{% highlight C# %} +{% highlight c# %} - // Draw polygon cloud annotation - pdfViewer.AnnotationMode = AnnotationMode.Polygon; - pdfViewer.AnnotationSettings.Rectangle.BorederStyle = BorderStyle.Cloudy; + // Draw polygon cloud annotation + PdfViewer.AnnotationMode = AnnotationMode.Polygon; + PdfViewer.AnnotationSettings.Polygon.BorderStyle = BorderStyle.Cloudy; {% endhighlight %} {% endtabs %} ### Change the border style for the selected polygon annotation -You can change the border style of the selected polygon annotation programmatically by accessing the selected annotation instance. The selected annotation instance may be obtained from the [AnnotationSelected](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationSelected) event. The following example shows how to change the border style of selected polygon annotation. Similarly, you can modify the square annotations border style. +You can change the border style of the selected polygon annotation programmatically by accessing the selected annotation instance. You can obtain the selected annotation instance from the [AnnotationSelected](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AnnotationSelected) event. The following example shows how to change the border style of the selected polygon annotation. Similarly, you can modify the square annotation's border style. {% tabs %} -{% highlight C# %} +{% highlight c# %} /// /// Change the selected shape annotation border style. /// @@ -218,11 +217,10 @@ You can change the border style of the selected polygon annotation programmatica void ChangeBorderStyleOfSelectedPolygonAnnotation(Annotation selectedAnnotation) { // Typecast the selected annotation as polygon annotation. - if (selectedAnnotation is PolygonAnnotation polygonAnnotation) - { - polygonAnnotation.BorderStyle = BorderStyle.Cloudy; // Change the border style to cloud. - } - + if (selectedAnnotation is PolygonAnnotation polygonAnnotation) + { + polygonAnnotation.BorderStyle = BorderStyle.Cloudy; // Change the border style to cloud. + } } {% endhighlight %} {% endtabs %} @@ -235,43 +233,49 @@ You can add cloud annotation to a PDF document using the built-in toolbar. ![Drawing cloud in mobile](Images/Annotations/mobile-cloud.gif) -### Add cloud shape annotation programmatically -You can create and add cloud polygon annotation to a PDF document programmatically using the [AddAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AddAnnotation_Syncfusion_Maui_PdfViewer_Annotation_) method of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following example explains how to create a cloud polygon annotation and add it to the first page of a PDF document. Similarly, you can add a square also. +### Add a cloud shape annotation programmatically + +You can create and add a cloud polygon annotation to a PDF document programmatically using the [AddAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_AddAnnotation_Syncfusion_Maui_PdfViewer_Annotation_) method of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following example explains how to create a cloud polygon annotation and add it to the first page of a PDF document. Similarly, you can add a square. {% tabs %} -{% highlight C# %} -PolygonAnnotation CreateCloudAnnoation() +{% highlight c# %} +PolygonAnnotation CreateCloudAnnotation() { int pageNumber = 1; // Define the points for the polygon in the PDF coordinates. - List polygonPoints = new List - { new PointF(10, 10), - new PointF(100, 10), - new PointF(100, 100), - new PointF(10, 100) - }; + List polygonPoints = new List + { new PointF(10, 10), + new PointF(100, 10), + new PointF(100, 100), + new PointF(10, 100) + }; // Create a cloud border style polygon annotation. - PolygonAnnotation annotation = new PolygonAnnotation (polygonPoints, pageNumber); - + PolygonAnnotation annotation = new PolygonAnnotation(polygonPoints, pageNumber); + // Set the border style appearance for the polygon annotation. - annotation.BorderStyle = BorderStyle.Cloudy // set the border style + annotation.BorderStyle = BorderStyle.Cloudy; // set the border style return annotation; } void AddCloudAnnotation() { - Annotation polygonAnnotation = CreateCloudAnnoation(); + Annotation polygonAnnotation = CreateCloudAnnotation(); //Add the cloud border style polygon annotation to the PDF document using the AddAnnotation method of the `SfPdfViewer` instance. - PdfViewer.AddAnnotation(polygonAnnotation ); + PdfViewer.AddAnnotation(polygonAnnotation); } {% endhighlight %} {% endtabs %} ## See Also + - [Annotations Overview](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-overview) -- [Add, Remove, and Modify Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/add-remove-modify-annotations) +- [Add, Remove, and Edit Annotations](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/add-remove-modify-annotations) - [Undo and Redo](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/undo-redo) +- [Comments](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/annotations-comment) +- [Toolbar](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/toolbar) +- [Free Text](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/free-text) +- [Ink](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/maui/ink) diff --git a/Document-Processing/PDF/PDF-Viewer/maui/Undo-Redo.md b/Document-Processing/PDF/PDF-Viewer/maui/Undo-Redo.md index 13eda6edb0..4a425c385c 100644 --- a/Document-Processing/PDF/PDF-Viewer/maui/Undo-Redo.md +++ b/Document-Processing/PDF/PDF-Viewer/maui/Undo-Redo.md @@ -10,7 +10,7 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne # Undo and Redo in .NET MAUI PDF Viewer (SfPdfViewer) -If you performed any undesired actions when adding, removing, moving, resizing or editing annotations, you can undo and redo the action to restore the previous state. This section will go through how to perform the undo and redo the changes made on the annotations. +If you performed any undesired actions when adding, removing, moving, resizing, or editing annotations, you can undo and redo the action to restore the previous state. This section explains how to undo and redo changes made to annotations. For desktop platforms such as Windows and macOS, you can also use the following shortcut keys to perform the actions. @@ -34,14 +34,14 @@ For desktop platforms such as Windows and macOS, you can also use the following ## Undo -You can perform undo to reverse the most recent action performed on the annotations using the [UndoCommand](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_UndoCommand) of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following code examples explain how to bind the command to a button in XAML to perform the action on button click, and also execute the command programmatically as well. +You can undo the most recent action performed on the annotations using the [UndoCommand](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_UndoCommand) of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following code examples show how to bind the command to a button in XAML to perform the action on button click, and how to execute the command programmatically. {% tabs %} -{% highlight XAML %} +{% highlight xaml %}