Deleting
- 2 minutes to read
The PDF Document Processor can delete text markup annotations specified in the PdfMarkupAnnotationData collection by calling the PdfDocumentProcessor.DeleteMarkupAnnotations method.
To delete a specific markup annotation from a page, call the PdfDocumentProcessor.DeleteMarkupAnnotation method, passing the PdfMarkupAnnotationData object with annotation data as an argument to this method.
To retrieve the markup annotations, call the PdfDocumentProcessor.GetMarkupAnnotationData method, specifying the page number.
Example
This example shows how to delete text markup annotations created by a particular author.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-delete-particular-markup-annotations-from-a-page-t549297
Imports DevExpress.Pdf
Imports System.Linq
Namespace RemoveSpecificMarkupAnnotations
Friend Class Program
Shared Sub Main(ByVal args() As String)
' Create a PDF Document Processor.
Using processor As New PdfDocumentProcessor()
' Load a document.
processor.LoadDocument("..\..\Document.pdf")
For i As Integer = 0 To processor.Document.Pages.Count
' Remove Bill Smith's markup annotations from a page.
processor.DeleteMarkupAnnotations(processor.GetMarkupAnnotationData(i).Where(Function(annotation) annotation.Author.Contains("Bill Smith")))
' Save the result document.
processor.SaveDocument("..\..\Result.pdf")
Next i
End Using
End Sub
End Class
End Namespace