diff --git a/xamarin-android-toc.html b/xamarin-android-toc.html index 9f07d890..18070e22 100644 --- a/xamarin-android-toc.html +++ b/xamarin-android-toc.html @@ -457,6 +457,7 @@
  • Free text annotations
  • Text markup annotations
  • Bookmark Navigation
  • +
  • Working with PDF coordinates
  • Working with PDF forms
  • Working with ScrollHead
  • Localization
  • diff --git a/xamarin-android/SfPdfViewer/FreeText-Annotation.md b/xamarin-android/SfPdfViewer/FreeText-Annotation.md index fc0b7ee4..bae82b3a 100644 --- a/xamarin-android/SfPdfViewer/FreeText-Annotation.md +++ b/xamarin-android/SfPdfViewer/FreeText-Annotation.md @@ -371,6 +371,56 @@ private void PdfViewer_FreeTextAnnotationRemoved(object sender, FreeTextAnnotati {% endhighlight %} {% endtabs %} +## How to lock or unlock the free text annotations? + +To lock or unlock all the free text annotation, set the `IsLocked` API to `true` or `false` respectively, and the following sample explains the same. But other annotation types can be moved, resized, removed or their attributes can be changed. + +{% tabs %} +{% highlight c# %} + +//Disable the free text annotation interaction such as move, resize, remove, and attributes changes. +pdfViewerControl.AnnotationSettings.FreeText.IsLocked = true; + +{% endhighlight %} +{% endtabs %} + +Interactions with free text annotation types such as move, resize, remove or attribute changes will be allowed only if the `SfPdfViewer.AnnotationSettings.IsLocked` API is set to `false`. The following code prevents the unlocking of the free text annotations, although the `IsLocked` property of the free text annotation is set to `false`. + +{% tabs %} +{% highlight c# %} + +//Disable the free text annotation interaction, though its 'IsLocked' property is set to ‘false’ . +pdfViewerControl.AnnotationSettings.IsLocked = true; +pdfViewerControl.AnnotationSettings.FreeText.IsLocked = false; + +{% endhighlight %} +{% endtabs %} + +## How to enable or disable the free text annotation selection? + +To enable or disable the free text annotation selection, set the `Constraints` API to `AnnotationConstraints.Selectable` or `~AnnotationConstraints.Selectable` respectively, and the following sample explains the same. But other annotation types can be selected, moved, resized, removed or their attributes can be changed. + +{% tabs %} +{% highlight c# %} + +//Disable the selection of free text annotations. +pdfViewerControl.AnnotationSettings.FreeText.Constraints = ~AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + +Free text annotation selection will be allowed only if the `SfPdfViewer.AnnotationSettings.Constraints` API is set to `AnnotationConstraints.Selectable`. The following code prevents the free text annotations selection, even though the `Constraints` property of the free text annotation is set to `AnnotationConstraints.Selectable`. + +{% tabs %} +{% highlight c# %} + +//Disable the free text annotation selection, though its 'Constraints' property is set to ‘AnnotationConstraints.Selectable’ +pdfViewerControl.AnnotationSettings.Constraints= ~AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.FreeText.Constraints = AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + ## How to get and set the name of the free text annotations? The PDF Viewer allows the users to get and set the name of free text annotations through the [Name](https://help.syncfusion.com/cr/xamarin-android/Syncfusion.SfPdfViewer.Android.IAnnotation.html#Syncfusion_SfPdfViewer_Android_IAnnotation_Name) API. diff --git a/xamarin-android/SfPdfViewer/Getting-Started.md b/xamarin-android/SfPdfViewer/Getting-Started.md index 635575a8..dbd8e758 100644 --- a/xamarin-android/SfPdfViewer/Getting-Started.md +++ b/xamarin-android/SfPdfViewer/Getting-Started.md @@ -401,6 +401,36 @@ private void PageDownButton_Click(object sender, System.EventArgs e) N>When the current page is the first page, GoToPreviousPage method will not have any effect. Similarly, when in last page, GoToNextPage method will not have any effect. +## How to lock or unlock all the annotations? + +To lock or unlock all the annotations in a PDF, set the `SfPdfViewer.AnnotationSettings.IsLocked` API to `true` or `false` respectively. The default value of the API is false, and when it is set to true, annotations can be selected, but resizing, moving, editing, and removing actions will be disabled. Only the tapped and selected events from the annotations will be raised. The following code sample explains the same. + +{% tabs %} +{% highlight c# %} + +//Lock all the annotations +pdfViewerControl.AnnotationSettings.IsLocked = true; + +{% endhighlight %} +{% endtabs %} + +N>The lock operation can also be enabled or disabled for a particular annotation type such as shape, free text, text markup, etc. Please find the code samples to enable or disable interaction for particular annotation from their respective sections. + +## How to enable or disable the annotation selection? + +To enable or disable the annotation selection, set the `SfPdfViewer.AnnotationSettings.Constraints` API to `AnnotationConstraints.Selectable` or `~AnnotationConstraints.Selectable` respectively. Annotations will be selected by default, and when this API is set to `~AnnotationConstraints.Selectable`, annotation selection, moving, resizing, removing and attribute changes will be disabled. Only the tapped events of the annotations will be raised. The following code sample explains the same. + +{% tabs %} +{% highlight c# %} + +//Disable the selection of all annotation types. +pdfViewerControl.AnnotationSettings.Constraints = ~AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + +N>The selection operation can also be enabled or disabled for a particular annotation type such as shape, free text, text markup, etc. Please find the code samples to enable or disable interaction for particular annotation from their respective sections. + ## How to get the list of annotations present in the PDF? By using `Annotations` property, You can get the list of annotations present in the PDF document. diff --git a/xamarin-android/SfPdfViewer/Handwritten-Signature.md b/xamarin-android/SfPdfViewer/Handwritten-Signature.md index 3499af2d..fb151103 100644 --- a/xamarin-android/SfPdfViewer/Handwritten-Signature.md +++ b/xamarin-android/SfPdfViewer/Handwritten-Signature.md @@ -192,6 +192,56 @@ private void PdfViewer_InkSelected(object sender, Syncfusion.SfPdfViewer.Android {% endhighlight %} {% endtabs %} +## How to lock or unlock the handwritten signature? + +To lock or unlock all the handwritten signature, set the `IsLocked` API to `true` or `false` respectively, and the following sample explains the same. But other annotation types can be moved, resized, removed or their attributes can be changed. + +{% tabs %} +{% highlight c# %} + +//Disable the handwritten signature interaction such as move, resize, remove, and attributes changes. +pdfViewerControl.AnnotationSettings.HandwrittenSignature.IsLocked = true; + +{% endhighlight %} +{% endtabs %} + +Interactions with handwritten signature types such as move, resize, remove or attribute changes will be allowed only if the `SfPdfViewer.AnnotationSettings.IsLocked` API is set to `false`. The following code prevents the unlocking of the handwritten signatures, although the `IsLocked` property of the handwritten signature is set to `false`. + +{% tabs %} +{% highlight c# %} + +//Disable the handwritten signature interaction, though its 'IsLocked' property is set to ‘false’ . +pdfViewerControl.AnnotationSettings.IsLocked = true; +pdfViewerControl.AnnotationSettings.HandwrittenSignature.IsLocked = false; + +{% endhighlight %} +{% endtabs %} + +## How to enable or disable the handwritten signature selection? + +To enable or disable the handwritten signature selection, set the `Constraints` API to `AnnotationConstraints.Selectable` or `~AnnotationConstraints.Selectable` respectively, and the following sample explains the same. But other annotation types can be selected, moved, resized, removed or their attributes can be changed. + +{% tabs %} +{% highlight c# %} + +//Disable the selection of handwritten signatures. +pdfViewerControl.AnnotationSettings.HandwrittenSignature.Constraints = ~AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + +Handwritten signature selection will be allowed only if the `SfPdfViewer.AnnotationSettings.Constraints` API is set to `AnnotationConstraints.Selectable`. The following code prevents the handwritten signatures selection, even though the `Constraints` property of the handwritten signature annotation is set to `AnnotationConstraints.Selectable`. + +{% tabs %} +{% highlight c# %} + +//Disable the handwritten signature selection, though its 'Constraints' property is set to ‘AnnotationConstraints.Selectable’ +pdfViewerControl.AnnotationSettings.Constraints= ~AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.HandwrittenSignature.Constraints = AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + ## How to get and set the name of the handwritten signatures? The PDF Viewer allows the users to get and set the name of handwritten signatures through the [Name](https://help.syncfusion.com/cr/xamarin-android/Syncfusion.SfPdfViewer.Android.IAnnotation.html#Syncfusion_SfPdfViewer_Android_IAnnotation_Name) API. diff --git a/xamarin-android/SfPdfViewer/Ink.md b/xamarin-android/SfPdfViewer/Ink.md index 41276c97..3a43a549 100644 --- a/xamarin-android/SfPdfViewer/Ink.md +++ b/xamarin-android/SfPdfViewer/Ink.md @@ -524,6 +524,56 @@ private void PdfViewer_AnnotationMovedOrResized(object sender, AnnotationMovedOr {% endhighlight %} {% endtabs %} +## How to lock or unlock the ink annotations? + +To lock or unlock all the ink annotation, set the `IsLocked` API to `true` or `false` respectively, and the following sample explains the same. But other annotation types can be moved, resized, removed or their attributes can be changed. + +{% tabs %} +{% highlight c# %} + +//Disable the ink annotation interaction such as move, resize, remove, and attributes changes. +pdfViewerControl.AnnotationSettings.Ink.IsLocked = true; + +{% endhighlight %} +{% endtabs %} + +Interactions with ink annotation types such as move, resize, remove or attribute changes will be allowed only if the `SfPdfViewer.AnnotationSettings.IsLocked` API is set to `false`. The following code prevents the unlocking of the ink annotations, although the `IsLocked` property of the ink annotation is set to `false`. + +{% tabs %} +{% highlight c# %} + +//Disable the ink annotation interaction, though its 'IsLocked' property is set to ‘false’ . +pdfViewerControl.AnnotationSettings.IsLocked = true; +pdfViewerControl.AnnotationSettings.Ink.IsLocked = false; + +{% endhighlight %} +{% endtabs %} + +## How to enable or disable the ink annotation selection? + +To enable or disable the ink annotation selection, set the `Constraints` API to `AnnotationConstraints.Selectable` or `~AnnotationConstraints.Selectable` respectively, and the following sample explains the same. But other annotation types can be selected, moved, resized, removed or their attributes can be changed. + +{% tabs %} +{% highlight c# %} + +//Disable the selection of ink annotations. +pdfViewerControl.AnnotationSettings.Ink.Constraints = ~AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + +Ink annotation selection will be allowed only if the `SfPdfViewer.AnnotationSettings.Constraints` API is set to `AnnotationConstraints.Selectable`. The following code prevents the ink annotations selection, even though the `Constraints` property of the ink annotation is set to `AnnotationConstraints.Selectable`. + +{% tabs %} +{% highlight c# %} + +//Disable the ink annotation selection, though its 'Constraints' property is set to ‘AnnotationConstraints.Selectable’ +pdfViewerControl.AnnotationSettings.Constraints= ~AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.Ink.Constraints = AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + ## How to render Ink strokes using custom ink points? By default, ink strokes are drawn by recording the points on the screen traversed by the input device (stylus or finger). The quality of the strokes thus drawn may not be satisfactory as it considers only raw points. If needed, the points can be modified using any algorithms to smoothen the strokes. diff --git a/xamarin-android/SfPdfViewer/Shape-Annotation.md b/xamarin-android/SfPdfViewer/Shape-Annotation.md index 2247696c..07f181da 100644 --- a/xamarin-android/SfPdfViewer/Shape-Annotation.md +++ b/xamarin-android/SfPdfViewer/Shape-Annotation.md @@ -466,39 +466,37 @@ private void PdfViewer_ShapeAnnotationRemoved(object sender, ShapeAnnotationRemo {% endhighlight %} {% endtabs %} -## How to enable or disable shape annotation interaction? - -The interaction operation can be enabled or disabled for shape annotation alone by setting the `IsLocked` API to `false` or `true` respectively. - -For example, the following code disables the interaction operations for all shape annotations in the PDF. But other annotation types can be selected, moved, resized, or removed. +## How to lock or unlock the shape annotations? + +To lock or unlock all the shape annotation, set the `IsLocked` API to `true` or `false` respectively, and the following sample explains the same. But other annotation types can be moved, resized, removed or their attributes can be changed. {% tabs %} {% highlight c# %} -//Disable the arrow annotation interaction +//Disable the arrow annotation interaction such as move, resize, remove, and attributes changes. pdfViewerControl.AnnotationSettings.Arrow.Settings.IsLocked = true; - -//Disable the line annotation interaction + +//Disable the line annotation interaction such as move, resize, remove, and attributes changes. pdfViewerControl.AnnotationSettings.Line.Settings.IsLocked = true; - -//Disable the rectangle annotation interaction + +//Disable the rectangle annotation interaction such as move, resize, remove, and attributes changes. pdfViewerControl.AnnotationSettings.Rectangle.Settings.IsLocked = true; - -//Disable the circle annotation interaction + +//Disable the circle annotation interaction such as move, resize, remove, and attributes changes. pdfViewerControl.AnnotationSettings.Circle.Settings.IsLocked = true; - -//Disable the polygon annotation interaction + +//Disable the polygon annotation interaction such as move, resize, remove, and attributes changes. pdfViewerControl.AnnotationSettings.Polygon.Settings.IsLocked = true; {% endhighlight %} {% endtabs %} - -The interaction with shape annotation types will be allowed only if the [`SfPdfViewer.AnnotationSettings.IsLocked`](https://help.syncfusion.com/cr/xamarin-android/Syncfusion.SfPdfViewer.Android.AnnotationSettings.html#Syncfusion_SfPdfViewer_Android_AnnotationSettings_IsLocked) API is set to `false`. The following code does not allow the interactions with shape annotations, although the `IsLocked` property of the shape annotation is set to `false`. - + +Interactions with shape annotation types such as move, resize, remove or attribute changes will be allowed only if the `SfPdfViewer.AnnotationSettings.IsLocked` API is set to `false`. The following code prevents the unlocking of the shape annotations, although the `IsLocked` property of the shape annotation is set to `false`. + {% tabs %} {% highlight c# %} -//Disables the shape annotation interaction, though its 'IsLocked' property is set to ‘false’ +//Disable the shape annotation interaction, though its 'IsLocked' property is set to ‘false’ . pdfViewerControl.AnnotationSettings.IsLocked = true; pdfViewerControl.AnnotationSettings.Arrow.Settings.IsLocked = false; pdfViewerControl.AnnotationSettings.Line.Settings.IsLocked = false; @@ -509,7 +507,48 @@ pdfViewerControl.AnnotationSettings.Polygon.Settings.IsLocked = false; {% endhighlight %} {% endtabs %} -N> The `IsLocked` properties of the classes [`RectangleAnnotation`](https://help.syncfusion.com/cr/xamarin-android/Syncfusion.SfPdfViewer.Android.RectangleAnnotation.html), [`CircleAnnotation`](https://help.syncfusion.com/cr/xamarin-android/Syncfusion.SfPdfViewer.Android.CircleAnnotation.html), [`LineAnnotation`](https://help.syncfusion.com/cr/xamarin-android/Syncfusion.SfPdfViewer.Android.LineAnnotation.html) and [`ArrowAnnotation`](https://help.syncfusion.com/cr/xamarin-android/Syncfusion.SfPdfViewer.Android.ArrowAnnotation.html) have been marked as obsolete. Use the `RectangleAnnotation.Settings.IsLocked`, `CircleAnnotation.Settings.IsLocked`, `LineAnnotation.Settings.IsLocked` and `ArrowAnnotation.Settings.IsLocked` properties instead. +N> The `IsLocked` properties of the classes [RectangleAnnotation](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfPdfViewer.XForms.RectangleAnnotation.html), [CircleAnnotation](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfPdfViewer.XForms.CircleAnnotation.html), [LineAnnotation](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfPdfViewer.XForms.LineAnnotation.html) and [ArrowAnnotation](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfPdfViewer.XForms.ArrowAnnotation.html) have been marked as obsolete. Use the `RectangleAnnotation.Settings.IsLocked`, `CircleAnnotation.Settings.IsLocked`, `LineAnnotation.Settings.IsLocked` and `ArrowAnnotation.Settings.IsLocked` properties instead. + +## How to enable or disable the shape annotation selection? + +To enable or disable the shape annotation selection, set the `Constraints` API to `AnnotationConstraints.Selectable` or `~AnnotationConstraints.Selectable` respectively, and the following sample explains the same. But other annotation types can be selected, moved, resized, removed or their attributes can be changed. + +{% tabs %} +{% highlight c# %} + +//Disable the selection of arrow annotations. +pdfViewerControl.AnnotationSettings.Arrow.Settings.Constraints = ~AnnotationConstraints.Selectable; + +//Disable the selection of line annotations. +pdfViewerControl.AnnotationSettings.Line.Settings.Constraints = ~AnnotationConstraints.Selectable; + +//Disable the selection of rectangle annotations. +pdfViewerControl.AnnotationSettings.Rectangle.Settings.Constraints = ~AnnotationConstraints.Selectable; + +//Disable the selection of circle annotations. +pdfViewerControl.AnnotationSettings.Circle.Settings.Constraints = ~AnnotationConstraints.Selectable; + +//Disable the selection of polygon annotations. +pdfViewerControl.AnnotationSettings.Polygon.Settings.Constraints = ~AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + +Shape annotation selection will be allowed only if the `SfPdfViewer.AnnotationSettings.Constraints` API is set to `AnnotationConstraints.Selectable`. The following code prevents the shape annotations selection, even though the `Constraints` property of the shape annotation is set to `AnnotationConstraints.Selectable`. + +{% tabs %} +{% highlight c# %} + +//Disable the shape annotation selection, though its 'Constraints' property is set to ‘AnnotationConstraints.Selectable’ +pdfViewerControl.AnnotationSettings.Constraints= ~AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.Arrow.Settings.Constraints = AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.Line.Settings.Constraints = AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.Rectangle.Settings.Constraints = AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.Circle.Settings.Constraints = AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.Polygon.Settings.Constraints = AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} ## How to get and set the name of the shape annotations? diff --git a/xamarin-android/SfPdfViewer/TextMarkup.md b/xamarin-android/SfPdfViewer/TextMarkup.md index 8559e8e5..2c768583 100644 --- a/xamarin-android/SfPdfViewer/TextMarkup.md +++ b/xamarin-android/SfPdfViewer/TextMarkup.md @@ -605,6 +605,72 @@ private void SaveButton_Click(object sender, EventArgs e) {% endtabs %} N>The CanUndo property is used to identify whether a document loaded in the PDF viewer is edited or not. When this property is set to true, means that the document in the PDF viewer is edited. +## How to lock or unlock the text markup annotations? + +To lock or unlock all the text markup annotation, set the `IsLocked` API to `true` or `false` respectively, and the following sample explains the same. But other annotation types can be moved, resized, removed or their attributes can be changed. + +{% tabs %} +{% highlight c# %} + +//Disable the text markup highlight annotation interaction such as remove and attributes changes. +pdfViewerControl.AnnotationSettings.TextMarkup.Highlight.IsLocked = true; + +//Disable the text markup underline annotation interaction such as remove and attributes changes. +pdfViewerControl.AnnotationSettings.TextMarkup.Underline.IsLocked = true; + +//Disable the text markup strikethrough annotation interaction such as remove and attributes changes. +pdfViewerControl.AnnotationSettings.TextMarkup.Strikethrough.IsLocked = true; + +{% endhighlight %} +{% endtabs %} + +Interactions with text markup annotation types such as remove or attribute changes will be allowed only if the `SfPdfViewer.AnnotationSettings.IsLocked` API is set to `false`. The following code prevents the unlocking of the text markup annotations, although the `IsLocked` property of the text markup annotation is set to `false`. + +{% tabs %} +{% highlight c# %} + +//Disable the text markup annotation interaction, though its 'IsLocked' property is set to ‘false’ +pdfViewerControl.AnnotationSettings.IsLocked = true; +pdfViewerControl.AnnotationSettings.TextMarkup.Highlight.IsLocked = false; +pdfViewerControl.AnnotationSettings.TextMarkup.Underline.IsLocked = false; +pdfViewerControl.AnnotationSettings.TextMarkup.Strikethrough.IsLocked = false; + +{% endhighlight %} +{% endtabs %} + +## How to enable or disable the text markup annotation selection? + +To enable or disable the text markup annotation selection, set the `Constraints` API to `AnnotationConstraints.Selectable` or `~AnnotationConstraints.Selectable` respectively, and the following sample explains the same. But other annotation types can be selected, moved, resized, removed or their attributes can be changed. + +{% tabs %} +{% highlight c# %} + +//Disable the selection of text markup highlight annotation +pdfViewerControl.AnnotationSettings.TextMarkup.Highlight.Constraints = ~AnnotationConstraints.Selectable; + +//Disable the selection of text markup underline annotation +pdfViewerControl.AnnotationSettings.TextMarkup.Underline.Constraints = ~AnnotationConstraints.Selectable; + +//Disable the selection of text markup strikethrough annotation +pdfViewerControl.AnnotationSettings.TextMarkup.Strikethrough.Constraints = ~AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + +Text markup annotation selection will be allowed only if the `SfPdfViewer.AnnotationSettings.Constraints` API is set to `AnnotationConstraints.Selectable`. The following code prevents the text markup annotations selection, even though the `Constraints` property of the text markup annotation is set to `AnnotationConstraints.Selectable`. + +{% tabs %} +{% highlight c# %} + +//Disable the text markup annotation selection, though its 'Constraints' property is set to ‘AnnotationConstraints.Selectable’ +pdfViewerControl.AnnotationSettings.Constraints = ~AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.TextMarkup.Highlight.Constraints = AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.TextMarkup.Underline.Constraints = AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.TextMarkup.Strikethrough.Constraints = AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + ## How to get and set the name of the text markup annotations? The PDF Viewer allows the users to get and set the name of text markup annotations through the [Name](https://help.syncfusion.com/cr/xamarin-android/Syncfusion.SfPdfViewer.Android.IAnnotation.html#Syncfusion_SfPdfViewer_Android_IAnnotation_Name) API. diff --git a/xamarin-android/SfPdfViewer/Working-with-PDF-Coordinates.md b/xamarin-android/SfPdfViewer/Working-with-PDF-Coordinates.md new file mode 100644 index 00000000..cc343802 --- /dev/null +++ b/xamarin-android/SfPdfViewer/Working-with-PDF-Coordinates.md @@ -0,0 +1,164 @@ +--- +layout: post +title: PDF coordinates in Xamarin.Android Pdf Viewer control | Syncfusion +description: Learn here all about working with PDF coordinates and their conversions support in Syncfusion Xamarin.Android Pdf Viewer control and more. +platform: Xamarin.Android +control: SfPdfViewer +documentation: ug +--- + +# Working with PDF coordinates + +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. + +## Get and set scroll coordinates + +Navigate to the specified vertical and horizontal scroll offset coordinates in PDF Viewer using the `ScrollToOffset (HorizontalOffset, VerticalOffset)` method. You can also retrieve the current horizontal and vertical offset position by using the `HorizontalOffset` and `VerticalOffset` properties respectively in the SfPdfViewer class. + +{% tabs %} +{% highlight c# %} + +//Retrieve the current horizontal offset of the PdfViewerControl. +m_currentHorizontalOffset = pdfViewerControl.HorizontalOffset; + +//Retrieve the current vertical offset of the PdfViewerControl. +m_currentVerticalOffset = pdfViewerControl.VerticalOffset; + +//Scroll the content to the specified vertical offset position in the PdfViewerControl. +pdfViewerControl.ScrollToOffset(m_currentHorizontalOffset+10, m_currentVerticalOffset+10); + +{% endhighlight %} +{% endtabs %} + +## PDF Viewer's coordinates or client coordinates + +![PDF Viewer client coordinates](pdfviewer_images/ClientCoordinates.png) + +You can obtain the PDF Viewer's client area (viewport) coordinates using the `ClientRectangle` property and the following code sample explains the same. This property will return the coordinate value without the consideration of non-client elements like toolbars and scroll bars. + +{% tabs %} +{% highlight c# %} + +//Retrieve the coordinates of the PDF Viewer's client area (viewport) +Rectangle clientRectangle = pdfViewerControl.ClientRectangle; + +{% endhighlight %} +{% endtabs %} + +## PDF page coordinates + +![PDF page coordinates](pdfviewer_images/PageCoordinates.png) + +PDF page coordinates are represented in terms of 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 coordinate 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. + +## Convert PDF Viewer's coordinates to PDF page coordinates + +You can obtain the PDF page coordinates using the `ConvertClientPointToPagePoint(clientPoint, pageNumber)` method by passing the client rectangle point and page number as input parameters. The following code sample explains how to convert a tapped client area position to a page point. + +{% tabs %} +{% highlight c# %} + +pdfViewerControl.Tapped += PdfViewerControl_Tapped; + +// Handle the tapped event. +private void PdfViewerControl_Tapped(object sender, TouchInteractionEventArgs e) +{ + //Retrieve the tapped client area position. + Point clientPoint = e.Position; + + //Retrieve the page number that corresponds to the client point. + int pageNumber = pdfViewerControl.GetPageNumberFromClientPoint(clientPoint) + + //Retrieve the page point. + Point pagePoint = pdfViewerControl.ConvertClientPointToPagePoint(clientPoint, pageNumber); +} + +{% endhighlight %} +{% endtabs %} + +## Convert PDF page coordinates to PDF Viewer's coordinates + +You can obtain the PDF page coordinates using the `ConvertPagePointToClientPoint(pagePoint, pageNumber)` method by passing the page point and page number as input parameters. The following code sample explains how to convert a shape annotation's position in the page coordinates to a client point. + +{% tabs %} +{% highlight c# %} + +//Get a shape annotation from the Annotations collection. +ShapeAnnotation shapeAnnotation = pdfViewerControl.Annotations[0] as ShapeAnnotation; + +//Get the annotation’s page number. +int pageNumber = shapeAnnotation.PageNumber; + +//Get the annotation bounds. +Rectangle annotationBounds = shapeAnnotation.Bounds; + +//Find the position of the annotation in page coordinates. +Point pagePoint = new Point(annotationBounds.X, annotationBounds.Y); + +//Convert the page point to client point. +Point clientPoint = pdfViewerControl.ConvertPagePointToClientPoint(pagePoint, pageNumber) + +{% endhighlight %} +{% endtabs %} + +## Convert PDF page coordinates to scroll coordinates + +You can obtain the PDF Viewer's scroll coordinates using the `ConvertPagePointToScrollPoint(pagePoint, pageNumber)` method by passing the page point and page number as input parameters. The following code example explains how to convert a shape annotation’s position in the page coordinates to a scroll point and then scrolling to that annotation's position in the PDF Viewer. + +{% tabs %} +{% highlight c# %} + +//Get a shape annotation from the Annotations collection. +ShapeAnnotation shapeAnnotation = pdfViewerControl.Annotations[0] as ShapeAnnotation; + +//Get the annotation bounds. +Rectangle annotationBounds = shapeAnnotation.Bounds; + +//Get the annotation’s page number. +int pageNumber = shapeAnnotation.PageNumber; + +//Find the position of the annotation in page coordinates. +Point pagePoint = new Point(annotationBounds.X, annotationBounds.Y); + +//Convert the page point to scroll point. +Point scrollPoint = pdfViewerControl.ConvertPagePointToScrollPoint(pagePoint, pageNumber) + +//Scrolling to the annotation’s position using the ScrollToOffset API. +pdfViewerControl.ScrollToOffset((float)scrollPoint.X, (float)scrollPoint.Y); + +{% endhighlight %} +{% endtabs %} + +## Bring a particular region to the view + +You can bring the given rectangular region to view and zoom in the document to fit the region in the PDF Viewer's client area (viewport) using the `ZoomToRect(rectangle)` method by passing the rectangular region as input parameter. The following code sample explains how to bring a particular into view. + +{% tabs %} +{% highlight c# %} + +//Get a shape annotation from the Annotations collection. +ShapeAnnotation shapeAnnotation = pdfViewerControl.Annotations[0] as ShapeAnnotation; + +//Get the annotation bounds. +Rectangle annotationBounds = shapeAnnotation.Bounds; + +//Convert the annotation bounds from the page coordinates to a rectangle in client coordinates. +Point topLeft = new Point(annotationBounds.Left, annotationBounds.Top); + +Point rightBottom = new Point(annotationBounds.Right, annotationBounds.Bottom); + +Point clientTopLeft = pdfViewerControl.ConvertPagePointToClientPoint(topLeft, pageNumber); + +Point clientRightBottom = pdfViewerControl.ConvertPagePointToClientPoint(rightBottom, pageNumber); + +double width = clientRightBottom.X - clientTopLeft.X; + +double height = clientRightBottom.Y - clientTopLeft.Y; + +Rectangle rectangleBounds = new Rectangle(clientTopLeft.X, clientTopLeft.Y, width, height); + +//Pass the converted rectangle in client coordinates to the ZoomToRect method. +pdfViewerControl.ZoomToRect(rectangleBounds); + +{% endhighlight %} +{% endtabs %} diff --git a/xamarin-android/SfPdfViewer/Working-with-custom-stamp-annotations.md b/xamarin-android/SfPdfViewer/Working-with-custom-stamp-annotations.md index 103332dc..522d4bf6 100644 --- a/xamarin-android/SfPdfViewer/Working-with-custom-stamp-annotations.md +++ b/xamarin-android/SfPdfViewer/Working-with-custom-stamp-annotations.md @@ -211,29 +211,52 @@ pdfViewer.StampAnnotationRemoved += PdfViewer_StampAnnotationRemoved; {% endhighlight %} {% endtabs %} -## How to enable or disable custom stamp annotation interaction? +## How to lock or unlock the custom stamp annotations? + +To lock or unlock all the custom stamp annotation, set the `IsLocked` API to `true` or `false` respectively, and the following sample explains the same. But other annotation types can be moved, resized, removed or their attributes can be changed. -The interaction operation can be enabled or disabled for custom stamp annotation alone by setting the `IsLocked` API to `false` or `true` respectively. +{% tabs %} +{% highlight c# %} -For example, the following code disables the interaction operations for all custom stamp annotations in the PDF. But other annotation types can be selected, moved, resized, or removed. +//Disable the custom stamp annotation interaction such as move, resize, remove, and attributes changes. +pdfViewerControl.AnnotationSettings.Stamp.IsLocked = true; +{% endhighlight %} +{% endtabs %} + +Interactions with custom stamp annotation types such as move, resize, remove or attribute changes will be allowed only if the `SfPdfViewer.AnnotationSettings.IsLocked` API is set to `false`. The following code prevents the unlocking of the custom stamp annotations, although the `IsLocked` property of the custom stamp annotation is set to `false`. + {% tabs %} {% highlight c# %} -//Disable the custom stamp annotation interaction -pdfViewerControl.AnnotationSettings.Stamp.IsLocked = true; +//Disable the custom stamp annotation interaction, though its 'IsLocked' property is set to ‘false’ . +pdfViewerControl.AnnotationSettings.IsLocked = true; +pdfViewerControl.AnnotationSettings.Stamp.IsLocked = false; {% endhighlight %} {% endtabs %} -The interaction with custom stamp annotation types will be allowed only if the [`SfPdfViewer.AnnotationSettings.IsLocked`](https://help.syncfusion.com/cr/xamarin-android/Syncfusion.SfPdfViewer.Android.AnnotationSettings.html#Syncfusion_SfPdfViewer_Android_AnnotationSettings_IsLocked) API is set to `false`. The following code does not allow the interactions with custom stamp annotations, although the `IsLocked` property of the custom stamp annotation is set to `false`. +## How to enable or disable the custom stamp annotation selection? + +To enable or disable the custom stamp annotation selection, set the `Constraints` API to `AnnotationConstraints.Selectable` or `~AnnotationConstraints.Selectable` respectively, and the following sample explains the same. But other annotation types can be selected, moved, resized, removed or their attributes can be changed. {% tabs %} {% highlight c# %} -//Disables the custom stamp annotation interaction, though its 'IsLocked' property is set to ‘false’ -pdfViewerControl.AnnotationSettings.IsLocked = true; -pdfViewerControl.AnnotationSettings.Stamp.IsLocked = false; +//Disable the selection of custom stamp annotations. +pdfViewerControl.AnnotationSettings.Stamp.Constraints = ~AnnotationConstraints.Selectable; + +{% endhighlight %} +{% endtabs %} + +Custom stamp annotation selection will be allowed only if the `SfPdfViewer.AnnotationSettings.Constraints` API is set to `AnnotationConstraints.Selectable`. The following code prevents the custom stamp annotations selection, even though the `Constraints` property of the custom stamp annotation is set to `AnnotationConstraints.Selectable`. + +{% tabs %} +{% highlight c# %} + +//Disable the custom stamp annotation selection, though its 'Constraints' property is set to ‘AnnotationConstraints.Selectable’ +pdfViewerControl.AnnotationSettings.Constraints= ~AnnotationConstraints.Selectable; +pdfViewerControl.AnnotationSettings.Stamp.Constraints = AnnotationConstraints.Selectable; {% endhighlight %} {% endtabs %} diff --git a/xamarin-android/SfPdfViewer/pdfviewer_images/ClientCoordinates.png b/xamarin-android/SfPdfViewer/pdfviewer_images/ClientCoordinates.png new file mode 100644 index 00000000..41827262 Binary files /dev/null and b/xamarin-android/SfPdfViewer/pdfviewer_images/ClientCoordinates.png differ diff --git a/xamarin-android/SfPdfViewer/pdfviewer_images/PageCoordinates.png b/xamarin-android/SfPdfViewer/pdfviewer_images/PageCoordinates.png new file mode 100644 index 00000000..e3fdbed5 Binary files /dev/null and b/xamarin-android/SfPdfViewer/pdfviewer_images/PageCoordinates.png differ