The following code is copied from Aspose ducument, with
Imports Aspose.Pdf
Imports Aspose.Pdf.Facades
Imports Aspose.Pdf.Color
in .NET 2008 IDE
The Gray colored part says "Type ... is not defined."
'open document
Dim pdfDocument As New Document("input.pdf")
'create TextAbsorber object to find all instances of the input search phrase
Dim textFragmentAbsorber As New TextFragmentAbsorber("\d{4}-\d{4}") 'like 1999-2000
'set text search option to specify regular expression usage
Dim textSearchOptions As New TextSearchOptions(True)
textFragmentAbsorber.TextSearchOptions = textSearchOptions
'accept the absorber for all the pages
pdfDocument.Pages.Accept(textFragmentAbsorber)
'get the extracted text fragments
Dim textFragmentCollection As TextFragmentCollection = textFragmentAbsorber.TextFragments
'loop through the fragments
For Each textFragment As TextFragment In textFragmentCollection
'update text and other properties
textFragment.Text = "New Phrase" 'ERROR: Object reference not set
to an instance of an object.
textFragment.TextState.Font = FontRepository.FindFont("Verdana")
textFragment.TextState.FontSize = 22
textFragment.TextState.ForegroundColor =
System.Drawing.Color.Blue
textFragment.TextState.BackgroundColor =
System.Drawing.Color.Green
Next textFragment
pdfDocument.Save("output.pdf")
sxia