Skip to content

DOCINFRA-2341_merged_using_automation #3308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions MAUI/PDF-Viewer/Add-Remove-Modify-Annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ 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
---

# Add, Remove and Edit Annotations in .NET MAUI PDF Viewer (SfPdfViewer)
# Add, Remove, and Edit Annotations in .NET MAUI PDF Viewer (SfPdfViewer)

This section will go through the various functions available 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 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.

## Add annotations to a PDF document

This section will go through 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 annotation.
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.

{% tabs %}
{% highlight c# %}
void AddCircleAnnotation()
{
int pageNumber = 1;
// Define the bounds for circle in the PDF coordinates.
// Define the bounds for the circle in the PDF coordinates.
RectF circleBounds = new RectF(10, 10, 100, 100);

// Create a circle annotation.
Expand All @@ -37,7 +37,7 @@ void AddCircleAnnotation()
annotation.BorderWidth = 2; //Stroke thickness
annotation.Opacity = 0.75f; // 75% Opacity

// Add the annotation to the PDF document using `AddAnnotation` method of `SfPdfViewer`.
// Add the annotation to the PDF document using the `AddAnnotation` method of `SfPdfViewer`.
PdfViewer.AddAnnotation(annotation);
}
{% endhighlight %}
Expand Down Expand Up @@ -69,7 +69,7 @@ This section will go through different methods of removing annotations from a PD

### Remove a specific annotation

You can remove an annotation from the document programmatically by providing the specific annotation instance as the parameter to [RemoveAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RemoveAnnotation_Syncfusion_Maui_PdfViewer_Annotation_) method of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following example shows how to remove the first annotation in the annotation collection from a PDF document.
You can remove an annotation from the document programmatically by providing the specific annotation instance as the parameter to the [RemoveAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RemoveAnnotation_Syncfusion_Maui_PdfViewer_Annotation_) method of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following example shows how to remove the first annotation in the annotation collection from a PDF document.

{% tabs %}
{% highlight c# %}
Expand All @@ -81,15 +81,15 @@ void RemoveFirstAnnotation()
//Obtain the first annotation in the annotation collection.
Annotation firstAnnotation = annotations[0];

//Remove the annotation using RemoveAnnotation method of `SfPdfViewer`.
//Remove the annotation using the RemoveAnnotation method of `SfPdfViewer`.
PdfViewer.RemoveAnnotation(firstAnnotation);
}
{% endhighlight %}
{% endtabs %}

### Remove all the annotations

You can remove all the annotations from a document programmatically by calling [RemoveAllAnnotations](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RemoveAllAnnotations) method. The following example shows how to remove all the annotations from a PDF document.
You can remove all the annotations from a document programmatically by calling the [RemoveAllAnnotations](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_RemoveAllAnnotations) method. The following example shows how to remove all the annotations from a PDF document.

{% tabs %}
{% highlight c# %}
Expand Down Expand Up @@ -127,7 +127,7 @@ This section will go through different methods of editing annotations in a PDF d

### Edit a specific annotation

You can edit the properties of an annotation from the document programmatically by accessing the specific annotation instance from the [Annotations](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_Annotations) property of the SfPdfViewer. The following example shows how to edit the first annotation in the annotation collection. Similarly, you can modify the other properties also.
You can edit the properties of an annotation from the document programmatically by accessing the specific annotation instance from the [Annotations](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_Annotations) property of the SfPdfViewer. The following example shows how to edit the first annotation in the annotation collection. Similarly, you can also modify the other properties.

{% tabs %}
{% highlight c# %}
Expand All @@ -143,7 +143,7 @@ void EditFirstAnnotation()
annotation.Color = Colors.Green; //Stroke color.
annotation.Opacity = 0.75f; // 75% Opacity

// Type cast to edit the properties of the specific annotation type. Here the first annotation is a circle annotation.
// Type cast to edit the properties of the specific annotation type. Here, the first annotation is a circle annotation.
if (annotation is CircleAnnotation circleAnnotation)
{
circleAnnotation.FillColor = Colors.Red; //Inner fill color.
Expand Down Expand Up @@ -174,11 +174,11 @@ private void OnAnnotationEdited(object sender, AnnotationEventArgs e)
{% endhighlight %}
{% endtabs %}

### Adding custom information to a 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 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 created 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. Within this code sample, we set the custom data to represent the creation date of the annotation.

{% tabs %}
{% highlight C# %}
Expand Down
4 changes: 2 additions & 2 deletions MAUI/PDF-Viewer/Annotation-Collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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 the 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. The following example explains how to use the property to obtain information about a square annotation that is the first on a specific document.

{% tabs %}
{% highlight c# %}
Expand All @@ -29,7 +29,7 @@ private void OnDocumentLoaded(object sender, EventArgs e)

if (annotations.Count > 0)
{
// Type cast the annotation to get the annotation specific properties.
// Type cast the annotation to get the annotation-specific properties.
if (annotations[0] is SquareAnnotation squareAnnotation)
{
RectF bounds = squareAnnotation.Bounds;
Expand Down
20 changes: 10 additions & 10 deletions MAUI/PDF-Viewer/Coordinates-Conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ 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
---

# Working with PDF coordinates systems in .NET MAUI PDF Viewer
# Working with PDF coordinate systems in .NET MAUI PDF Viewer

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.

## Client rectangle

The [ClientRectangle](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_ClientRectangle) in 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)

Expand All @@ -29,17 +29,17 @@ 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 is 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)

### Get page number from client point
### Get the page number from a client point

You can obtain the page number of the client point using the [GetPageNumberFromClientPoint(Point clientPoint)](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_GetPageNumberFromClientPoint_Microsoft_Maui_Graphics_Point_) method by passing the client point as input parameter. The following code sample explains how to get the page number from the client point.
You can obtain the page number of the client point using the [GetPageNumberFromClientPoint(Point clientPoint)](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_GetPageNumberFromClientPoint_Microsoft_Maui_Graphics_Point_) method by passing the client point as an input parameter. The following code sample explains how to get the page number from the client point.

{% tabs %}
{% highlight c# %}
//Subscribe the Tapped event of PDF Viewer
//Subscribe to the Tapped event of the PDF Viewer
PdfViewer.Tapped += PdfViewer_Tapped;

// Handle the tapped event.
Expand All @@ -55,7 +55,7 @@ private void PdfViewer_Tapped(object sender, GestureEventArgs e)

## PDF page coordinates

PDF page coordinates are represented in terms of device-independent coordinates 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 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.

![Page coordinates in .NET MAUI PDF Viewer](Images\Coordinates-Conversion\Page-Coordinates.png)

Expand All @@ -69,7 +69,7 @@ You can obtain the PDF page coordinates using the [ConvertClientPointToPagePoint

{% tabs %}
{% highlight c# %}
//Subscribe the Tapped event of PDF Viewer
//Subscribe to the Tapped event of the PDF Viewer
PdfViewer.Tapped += PdfViewer_Tapped;

// Handle the tapped event.
Expand Down Expand Up @@ -97,7 +97,7 @@ ReadOnlyObservableCollection<Annotation> annotations = PdfViewer.Annotations;
// Obtain the first annotation in the annotation collection.
Annotation annotation = annotations[0];

// Type cast to the specific annotation type. Here the first annotation is a square annotation.
// 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.
Expand All @@ -124,7 +124,7 @@ ReadOnlyObservableCollection<Annotation> annotations = PdfViewer.Annotations;
// Obtain the first annotation in the annotation collection.
Annotation annotation = annotations[0];

// Type cast to the specific annotation type. Here the first annotation is a square annotation.
// Type cast to the specific annotation type. Here, the first annotation is a square annotation.
if (annotation is SquareAnnotation squareAnnotation)
{
//Get the annotation bounds.
Expand Down
8 changes: 4 additions & 4 deletions MAUI/PDF-Viewer/Custom-Bookmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pdfViewer.IsOutlineViewVisible = true;
{% endhighlight %}
{% endtabs %}

## Accessing custom bookmarks collection
## Accessing the custom bookmarks collection

To access the custom bookmarks, you can use the [CustomBookmarks](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_CustomBookmarks) collection. This property provides the list of custom bookmarks in the PDF.

Expand All @@ -40,7 +40,7 @@ var customBookmarks = pdfViewer.CustomBookmarks;
{% endhighlight %}
{% endtabs %}

## Add , Edit and Remove custom bookmark
## Add, edit, and remove custom bookmarks

To add, edit, or remove custom bookmarks in a PDF viewer, you can use the [CustomBookmarks](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html#Syncfusion_Maui_PdfViewer_SfPdfViewer_CustomBookmarks) collection. This property provides access to the collection of custom bookmarks that can be manipulated to modify the bookmarks displayed in the viewer's bookmark view.

Expand All @@ -60,7 +60,7 @@ To add a custom bookmark, you can create a new instance of Bookmark and add it t
Bookmark newBookmark = new Bookmark()
{
Name = "New Bookmark",
PageNumber = 1, // Page number where the bookmark should to navigate
PageNumber = 1, // Page number where the bookmark should navigate
};

pdfViewer.CustomBookmarks.Add(newBookmark);
Expand Down Expand Up @@ -113,7 +113,7 @@ if (bookmarkToRemove != null)
{% endhighlight %}
{% endtabs %}

## Navigating to custom bookmark
## Navigating to a custom bookmark

### Navigating using UI

Expand Down
4 changes: 2 additions & 2 deletions MAUI/PDF-Viewer/Document-Link-Annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ documentation: ug

# 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 its destination. This type of link annotations is most often used to represent the table of contents of a PDF 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 its destination. This type of link annotation is most often used to represent the table of contents of a PDF document.

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 below code snippet illustrates disabling the 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.

{% tabs %}
{% highlight c# %}
Expand Down
2 changes: 1 addition & 1 deletion MAUI/PDF-Viewer/Document-Outline.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation: ug

# Document outline in .NET MAUI PDF Viewer

A PDF document may optionally have a document outline (also called as 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.
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

Expand Down
Loading