TextMarkupAnnotationType Enum
Lists text markup annotation types.
Declaration
public enum TextMarkupAnnotationType extends Enum<TextMarkupAnnotationType> implements IIntEnum
Members
| Name | Description |
|---|---|
HIGHLIGHT
|
Specifies a highlight text markup annotation. |
SQUIGGLY
|
Specifies a squiggly underline text markup annotation. |
STRIKE_OUT
|
Specifies a strikeout text markup annotation. |
UNDERLINE
|
Specifies an underline text markup annotation. |
fromValue(int value)
|
Returns the text markup annotation type with the specified integer value. |
getName()
|
Returns the text markup annotation type item name. |
getValue()
|
Returns the text markup annotation type integer value. |
toString()
|
Returns the string representation of the text markup annotation type. |
valueOf(String name)
|
Returns the text markup annotation type enum constant with the specified name. |
values()
|
Returns the available text markup annotation type constants. |
Remarks
Use the setType(TextMarkupAnnotationType value) method to specify the text markup annotation type.
The following code snippet highlights all occurrences of “external PDF Viewer“:
import com.devexpress.docs.pdf.*;
import java.nio.file.*;
import java.nio.channels.*;
import java.util.List;
public class Main {
public static void main(String[] args) throws Exception {
try (FileChannel channel = FileChannel.open(Path.of("Document.pdf"));
PdfDocument pdfDocument = new PdfDocument(channel)) {
// Search for text.
for (TextSearchInfo result : pdfDocument.findText("external PDF Viewer")) {
for (TextMatchInfo match : result.getMatches()) {
List<OrientedRectangle> bounds =
match.getMatchFragments().stream()
.map(fragment -> fragment.getRectangle())
.toList();
TextMarkupAnnotation annotation = new TextMarkupAnnotation(bounds);
annotation.setType(TextMarkupAnnotationType.HIGHLIGHT);
annotation.setColor(PdfColor.getYellow());
annotation.setTitle("John Smith");
annotation.setContent("Review this section.");
pdfDocument.getPages()
.get(result.getPageIndex())
.getAnnotations()
.add(annotation);
}
}
// Save the document.
try (WritableByteChannel summaryChannel =
FileChannel.open(
Path.of("Result.pdf"),
StandardOpenOption.CREATE,
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING)) {
pdfDocument.save(summaryChannel);
}
}
}
}