Creating
- 2 minutes to read
You can add the following text markup annotations to a page: highlight, strikeout, underline, and squiggly underline.
To add a text markup annotation to a page, call one of the overloaded PdfDocumentProcessor.AddTextMarkupAnnotation methods, where specify the annotation type, page number and a page area corresponding to the text that should be annotated on this page. These methods return the PdfTextMarkupAnnotationData object that represents the markup annotation data.
Note
If a specified page area does not correspond to text on the page, the annotation is not created and overloaded PdfDocumentProcessor.AddTextMarkupAnnotation methods return null.
Then, you can specify the annotation settings using the PdfMarkupAnnotationData class’s properties.
Example
Tip
A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T545395.
This example shows how to create a text markup annotation that highlights text in a document and specify the annotation properties.
using System;
using DevExpress.Pdf;
namespace CreateMarkupAnnotation {
class Program {
static void Main(string[] args) {
// Create a PDF Document Processor.
using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {
// Load a document.
processor.LoadDocument("..\\..\\Document.pdf");
// Add a text markup annotation to the first page for text corresponding to the specified page area.
PdfTextMarkupAnnotationData annot = processor.AddTextMarkupAnnotation(1, new PdfRectangle(90, 100, 240, 230),
PdfTextMarkupAnnotationType.Highlight);
if (annot != null) {
// Specify the annotation properties.
annot.Author = "Bill Smith";
annot.Contents = "Note";
annot.Color = new PdfRGBColor(0.8, 0.2, 0.1);
// Save the resulting document.
processor.SaveDocument("..\\..\\Result.pdf");
}
else
Console.WriteLine("The annotation cannot be added to a page. Make sure the specified page area corresponds to text on the page.");
}
}
}
}