Skip to content

Commit 640e4e7

Browse files
Merge branch 'master' into 'hotfix/hotfix-v19.3.0.43'
DOCINFRA-2256 Merged master to hotfix/hotfix-v19.3.0.43 using Automation See merge request content/wpf-docs!5197
2 parents 3a77faf + 65fe57f commit 640e4e7

File tree

1 file changed

+89
-89
lines changed

1 file changed

+89
-89
lines changed
Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,90 @@
1-
---
2-
layout: post
3-
title: How to lock an annotation in WPF pdf viewer | Syncfusion
4-
description: Learn about how to enable or disable lock option for an annotation programmatically or UI using WPF Pdf Viewer.
5-
platform: wpf
6-
control: PDF Viewer
7-
documentation: ug
8-
---
9-
10-
# Locking annotations in WPF PDF Viewer
11-
12-
The WPF PDF Viewer provides a support to enable or disable lock option for the annotation in a pdf document. When an annotation is locked, it cannot be moved, resized, and removed.
13-
14-
## Lock an annotation from code behind
15-
16-
The annotation can be locked either by default settings or by annotation changed events using the `IsLocked` API.
17-
18-
### Default settings
19-
20-
To lock an annotation, set the `IsLocked` value in annotation settings as true. The following code sample illustrates how to lock all annotations by default.
21-
22-
{% tabs %}
23-
{% highlight C# %}
24-
25-
private void Window_Loaded(object sender, RoutedEventArgs e)
26-
{
27-
PdfLoadedDocument pdf = new PdfLoadedDocument("Input.pdf");
28-
29-
//Loads the PDF document
30-
pdfviewer.Load(pdf);
31-
32-
//Sets the value to lock all annotations
33-
pdfviewer.PolygonAnnotationSettings.IsLocked = true;
34-
pdfviewer.PolylineAnnotationSettings.IsLocked = true;
35-
pdfviewer.CircleAnnotationSettings.IsLocked = true;
36-
pdfviewer.RectangleAnnotationSettings.IsLocked = true;
37-
pdfviewer.LineAnnotationSettings.IsLocked = true;
38-
pdfviewer.ArrowAnnotationSettings.IsLocked = true;
39-
pdfviewer.StickyNoteAnnotationSettings.IsLocked = true;
40-
pdfviewer.StampAnnotationSettings.IsLocked = true;
41-
pdfviewer.InkAnnotationSettings.IsLocked = true;
42-
pdfviewer.FreeTextAnnotationSettings.IsLocked = true;
43-
pdfviewer.HighlightAnnotationSettings.IsLocked = true;
44-
pdfviewer.UnderlineAnnotationSettings.IsLocked = true;
45-
pdfviewer.StrikethroughAnnotationSettings.IsLocked = true;
46-
47-
}
48-
49-
{% endhighlight %}
50-
{% endtabs %}
51-
52-
### Annotation changed event
53-
54-
To lock an annotation by annotation changed event, set the value of `IsLocked` in the annotation changed event as true. The following code sample illustrates how to lock sticky note annotation by using the annotation changed event while adding an annotation.
55-
56-
{% tabs %}
57-
{% highlight C# %}
58-
59-
//Wires the event handler for ` StickyNoteAnnotationChanged` event
60-
pdfviewer.StickyNoteAnnotationChanged += Pdfviewer_StickyNoteAnnotationChanged;
61-
62-
private void Pdfviewer_StickyNoteAnnotationChanged(object sender, StickyNoteAnnotationChangedEventArgs e)
63-
{
64-
65-
if (e.Action == AnnotationChangedAction.Add)
66-
{
67-
68-
//Sets the value to lock the annotation
69-
e.Settings.IsLocked = true;
70-
71-
}
72-
}
73-
74-
{% endhighlight %}
75-
{% endtabs %}
76-
77-
N> Similarly, you can implement it for all other annotations in code behind.
78-
79-
## Lock an annotation in UI
80-
81-
The check box control labeled as “Locked” will appear in the annotation properties window, allowing us to enable or disable lock option for the selected annotation.
82-
83-
The following image shows how to enable lock option for sticky note annotation in UI.
84-
85-
![Locking Annotations using WPF PDF Viewer](Annotation-images\Lock-Annotation-1.png)
86-
87-
N> Similarly, you can set it for all other annotations in UI.
88-
89-
1+
---
2+
layout: post
3+
title: How to lock an annotation in WPF pdf viewer | Syncfusion
4+
description: Learn about how to enable or disable lock option for an annotation programmatically or UI using WPF Pdf Viewer.
5+
platform: wpf
6+
control: PDF Viewer
7+
documentation: ug
8+
---
9+
10+
# Locking annotations in WPF PDF Viewer
11+
12+
The WPF PDF Viewer provides a support to enable or disable lock option for the annotation in a pdf document. When an annotation is locked, it cannot be moved, resized, and removed.
13+
14+
## Lock an annotation from code behind
15+
16+
The annotation can be locked either by default settings or by annotation changed events using the `IsLocked` API.
17+
18+
### Default settings
19+
20+
To lock an annotation, set the `IsLocked` value in annotation settings as true. The following code sample illustrates how to lock all annotations by default.
21+
22+
{% tabs %}
23+
{% highlight C# %}
24+
25+
private void Window_Loaded(object sender, RoutedEventArgs e)
26+
{
27+
PdfLoadedDocument pdf = new PdfLoadedDocument("Input.pdf");
28+
29+
//Loads the PDF document
30+
pdfviewer.Load(pdf);
31+
32+
//Sets the value to lock all annotations
33+
pdfviewer.PolygonAnnotationSettings.IsLocked = true;
34+
pdfviewer.PolylineAnnotationSettings.IsLocked = true;
35+
pdfviewer.CircleAnnotationSettings.IsLocked = true;
36+
pdfviewer.RectangleAnnotationSettings.IsLocked = true;
37+
pdfviewer.LineAnnotationSettings.IsLocked = true;
38+
pdfviewer.ArrowAnnotationSettings.IsLocked = true;
39+
pdfviewer.StickyNoteAnnotationSettings.IsLocked = true;
40+
pdfviewer.StampAnnotationSettings.IsLocked = true;
41+
pdfviewer.InkAnnotationSettings.IsLocked = true;
42+
pdfviewer.FreeTextAnnotationSettings.IsLocked = true;
43+
pdfviewer.HighlightAnnotationSettings.IsLocked = true;
44+
pdfviewer.UnderlineAnnotationSettings.IsLocked = true;
45+
pdfviewer.StrikethroughAnnotationSettings.IsLocked = true;
46+
47+
}
48+
49+
{% endhighlight %}
50+
{% endtabs %}
51+
52+
### Annotation changed event
53+
54+
To lock an annotation by annotation changed event, set the value of `IsLocked` in the annotation changed event as true. The following code sample illustrates how to lock sticky note annotation by using the annotation changed event while adding an annotation.
55+
56+
{% tabs %}
57+
{% highlight C# %}
58+
59+
//Wires the event handler for ` StickyNoteAnnotationChanged` event
60+
pdfviewer.StickyNoteAnnotationChanged += Pdfviewer_StickyNoteAnnotationChanged;
61+
62+
private void Pdfviewer_StickyNoteAnnotationChanged(object sender, StickyNoteAnnotationChangedEventArgs e)
63+
{
64+
65+
if (e.Action == AnnotationChangedAction.Add)
66+
{
67+
68+
//Sets the value to lock the annotation
69+
e.Settings.IsLocked = true;
70+
71+
}
72+
}
73+
74+
{% endhighlight %}
75+
{% endtabs %}
76+
77+
N> Similarly, you can implement it for all other annotations in code behind.
78+
79+
## Lock an annotation in UI
80+
81+
The check box control labeled as “Locked” will appear in the annotation properties window, allowing us to enable or disable lock option for the selected annotation.
82+
83+
The following image shows how to enable lock option for sticky note annotation in UI.
84+
85+
![Locking Annotations using WPF PDF Viewer](Annotation-images\Lock-Annotation-1.png)
86+
87+
N> Similarly, you can set it for all other annotations in UI.
88+
89+
9090
N> You can refer to our [WPF PDF Viewer](https://www.syncfusion.com/wpf-controls/pdf-viewer) feature tour page for its groundbreaking feature representations. You can also explore our [WPF PDF Viewer example](https://github.com/syncfusion/wpf-demos) to know how to render and configure the pdfviewer.

0 commit comments

Comments
 (0)