Skip to main content

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);
            }
        }
    }
}

Implements

com.devexpress.java.enums.IIntEnum

Inherited Members

java.lang.Enum.<T>valueOf(java.lang.Class<T>,java.lang.String)
java.lang.Enum.clone()
java.lang.Enum.compareTo(E)
java.lang.Enum.describeConstable()
java.lang.Enum.equals(java.lang.Object)
java.lang.Enum.finalize()
java.lang.Enum.getDeclaringClass()
java.lang.Enum.hashCode()
java.lang.Enum.name()
java.lang.Enum.ordinal()
java.lang.Enum.toString()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
java.lang.Enum
TextMarkupAnnotationType