- Change the default color of the squiggly annotation
- Change the default opacity of the squiggly annotation
- Change the default author and subject of the squiggly annotation
- Working with included/existing squiggly annotations
- Notification when the squiggly has changed
Contact Support
Squiggly text in PDF files using WPF PDF Viewer
20 Jan 20257 minutes to read
The WPF PDF Viewer allows users to use squiggly text in PDF files and provides options to edit or remove the existing squiggles. The squiggly inclusion mode can be enabled via the toolbar UI or the API. Once the squiggly inclusion mode is activated, you can squiggle the required text by selecting it. Hold the left mouse button to select the text and drag the mouse pointer over the text.
To enable the mode from UI, click the below icon in the default toolbar of PdfViewerControl.
NOTE
From version 19.4.0.48, we have updated our default text extraction engine to PDFium for extracting text information from PDF documents. We create text markup annotations in the PDF documents based on the text information. Please refer to the link for more details.
If you are using PdfDocumentView control, your own toolbar, or if you want enable the mode programmatically, change the AnnotationMode property of PDF Viewer to Squiggly, as shown in the below code example.
private void EnableSquigglyInclusionMode()
{
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Squiggly;
}
Private Sub EnableSquigglyInclusionMode()
pdfViewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Squiggly
End Sub
The following image shows the squiggled text in the PDF file.
Change the default color of the squiggly annotation
The squiggly color is red by default. However, you can change the default color of the squiggly programmatically, as shown in the following code example:
private void ChangeDefaultSquigglyColor()
{
pdfViewer.SquigglyAnnotationSettings.Color = System.Windows.Media.Colors.Blue;
}
Private Sub ChangeDefaultSquigglyColor()
pdfviewer.SquigglyAnnotationSettings.Color = System.Windows.Media.Colors.Blue
End Sub
Change the default opacity of the squiggly annotation
The squiggly opacity value is 1 by default. However, you can change the default opacity of the squiggly programmatically, as shown in the following code example:
private void ChangeDefaultSquigglyOpacity()
{
pdfViewer.SquigglyAnnotationSettings.Opacity = 0.5f;
}
Private Sub ChangeDefaultSquigglyOpacity()
pdfviewer.SquigglyAnnotationSettings.Opacity = 0.5F
End Sub
Change the default author and subject of the squiggly annotation
You can change the default author and subject of the squiggly annotation programmatically, as shown in the following code example:
private void ChangeDefaultSquigglyDetails()
{
pdfViewer.SquigglyAnnotationSettings.Author = "your name";
pdfViewer.SquigglyAnnotationSettings.Subject = "your subject";
}
Private Sub ChangeDefaultSquigglyDetails()
pdfViewer.SquigglyAnnotationSettings.Author = "your name"
pdfViewer.SquigglyAnnotationSettings.Subject = "your subject"
End Sub
Working with included/existing squiggly annotations
Squiggly annotation supports adding notes along with it and allows editing its color and opacity. To use these options, select the included/existing squiggly annotation and click right using the mouse. Over the selected annotation, a pop-up context menu will appear with the following options:
- Open the pop-up note
- Properties
- Delete
Open Pop-up notes
We can add notes to the squiggly annotation by choosing the Open Pop-up note option from the context menu. The following image illustrates the notes added to the selected squiggly annotation. The added notes will be saved along with the PDF document; if there are any existing notes, they will be displayed here.
Properties
Selecting properties from the context menu will display the Squiggly Properties window, which would consist of two tabs
- Appearance
- General
Appearance tab
The color and opacity of the squiggly annotation can be edited using the Appearance tab of the Squiggly Properties window.
Editing color of the annotation
The color of the selected squiggly annotation will be displayed in the color row in the appearance tab. Selecting the Color would display the color palette control, and choosing a color from the color palette and then clicking OK will apply the color to the squiggly annotation.
The following image illustrates how to change the color of the squiggly annotation included:
The following image illustrated the change in color of the included squiggly annotation:
Editing opacity of the annotation
The slider displayed in the Appearance tab will allow us to modify the opacity of the selected squiggly annotation. You can also modify the opacity of the selected squiggly annotation by giving numeric values in the opacity text box.
The following image illustrates how to change the opacity of the squiggly annotation:
The following image illustrates the change in opacity of the included squiggly annotation:
General tab
We can add/edit the default Author and Subject to the included squiggly annotation using General tab of the Squiggly Properties window.
The following image illustrates the change in Author and Subject of the included Squiggly annotation:
Deleting an annotation
Selecting the delete option from the context menu, displayed by right-clicking on the selected annotation, would delete the respective annotation from the PDF document.
The following image illustrates how to delete the included annotation from the PDF document:
Notification when the squiggly has changed
The TextMarkupAnnotationChanged event occurs when an squiggly annotation is added, removed or modified. The TextMarkupAnnotationChangedEventArgs provides information such as the type of the annotation, the action performed, and the annotation properties.
The following code shows how to wire and handle the event.
//wire the text markup changed event.
pdfViewer.TextMarkupAnnotationChanged += PdfViewer_TextMarkupAnnotationChanged;
private void PdfViewer_TextMarkupAnnotationChanged(object sender, TextMarkupAnnotationChangedEventArgs e)
{
//Get the action performed on the annotation
//AnnotationChangedAction to identify action performed for annotation
AnnotationChangedAction action = e.Action;
//Page index in which this shape annotation was modified
int pageNumber = e.PageNumber;
//Get annotation's new and old bounds (position and size).
RectangleF newBounds = e.NewBounds;
RectangleF oldBounds = e.OldBounds;
//To identify which type text markup annotation
TextMarkupAnnotationType type = e.Type;
TextMarkupAnnotationSettings settings = e.Settings;
//Annotation's properties which can be modify
string author = settings.Author;
string subject = settings.Subject;
string Text = settings.Text;
float opacity = settings.Opacity;
}
NOTE
You can refer to our WPF PDF Viewer feature tour page for its groundbreaking feature representations. You can also explore our WPF PDF Viewer example to know how to render and configure the pdfviewer.