Skip to main content

FreeTextAnnotation Class

Defines a free text annotation in a PDF document.

Declaration

public class FreeTextAnnotation extends MarkupAnnotation

Remarks

The following code snippet creates a free text annotation, specifies its author, content, and text appearance, and adds the annotation to a page:

package pdf;

import com.devexpress.docs.pdf.*;
import com.devexpress.system.drawing.*;

import java.nio.channels.*;
import java.nio.file.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (FileChannel fileChannel = FileChannel.open(Path.of("Document.pdf"));
             PdfDocument pdfDocument = new PdfDocument(fileChannel)) {

            Page page = pdfDocument.getPages().getFirst();

            createFreeTextAnnotation(page);

            // Save the document.
            try (WritableByteChannel channel =
                         FileChannel.open(Path.of("Result.pdf"),
                                 StandardOpenOption.CREATE,
                                 StandardOpenOption.WRITE,
                                 StandardOpenOption.TRUNCATE_EXISTING)) {

                pdfDocument.save(channel);
            }
        }
    }

    static void createFreeTextAnnotation(Page page) {
        FreeTextAnnotation annotation =
                new FreeTextAnnotation(
                        new RectangleF(200, 520, 260, 220));

        annotation.setTitle("John Smith");
        annotation.setSubject("Editorial Review");
        annotation.setContent("Update this section.");
        annotation.setTextJustification(TextJustification.LEFT_JUSTIFIED);
        annotation.setDefaultStyle("font: Times-Roman 12pt; color: #2B579A;");
        annotation.setOpacity(0.5);

        annotation.getPopup().setOpen(true);

        page.getAnnotations().add(annotation);
    }
}

The following screenshot illustrates the result:

Free Text Annotation, DevExpress PDF Document API for Java

Refer to the following help topic for additional information: Free Text Annotations.

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
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
JavaObject

FreeTextAnnotation(RectangleF bounds)

Initializes a new instance of the FreeTextAnnotation class with specified settings.

Declaration

public FreeTextAnnotation(RectangleF bounds)

Parameters

Name Type Description
bounds RectangleF

The annotation bounds.

Methods

getBorderEffect() Method

Returns the free text annotation border effect.

Declaration

public AnnotationBorderEffect getBorderEffect()

Returns

Type Description
AnnotationBorderEffect

The border effect.

getBorderStyle() Method

Returns the free text annotation border style.

Declaration

public AnnotationBorderStyle getBorderStyle()

Returns

Type Description
AnnotationBorderStyle

The border style.

getCallout() Method

Returns the free text annotation callout.

Declaration

public AnnotationCallout getCallout()

Returns

Type Description
AnnotationCallout

The callout.

getCalloutLineEndingStyle() Method

Returns the free text annotation callout line ending style.

Declaration

public AnnotationLineEndingStyle getCalloutLineEndingStyle()

Returns

Type Description
AnnotationLineEndingStyle

The callout line ending style.

getDefaultStyle() Method

Returns the free text annotation default style.

Declaration

public String getDefaultStyle()

Returns

Type Description
String

The default style.

getFinishCalloutLineEndingStyle() Method

Returns the free text annotation finish callout line ending style.

Declaration

public AnnotationLineEndingStyle getFinishCalloutLineEndingStyle()

Returns

Type Description
AnnotationLineEndingStyle

The finish callout line ending style.

getFreeTextIntent() Method

Returns the free text annotation intent.

Declaration

public FreeTextAnnotationIntent getFreeTextIntent()

Returns

Type Description
FreeTextAnnotationIntent

The free text annotation intent.

getOutlineFill() Method

Returns the free text annotation outline fill.

Declaration

public Fill getOutlineFill()

Returns

Type Description
Fill

The outline fill.

getPadding() Method

Returns the free text annotation padding.

Declaration

public Padding getPadding()

Returns

Type Description
Padding

The padding.

getTextAppearance() Method

Returns the free text annotation text appearance.

Declaration

public TextAppearance getTextAppearance()

Returns

Type Description
TextAppearance

The text appearance.

getTextJustification() Method

Returns the free text annotation text justification.

Declaration

public TextJustification getTextJustification()

Returns

Type Description
TextJustification

The text justification.

setBorderEffect(AnnotationBorderEffect value) Method

Sets the free text annotation border effect.

Declaration

public void setBorderEffect(AnnotationBorderEffect value)

Parameters

Name Type Description
value AnnotationBorderEffect

The border effect.

setBorderStyle(AnnotationBorderStyle value) Method

Sets the free text annotation border style.

Declaration

public void setBorderStyle(AnnotationBorderStyle value)

Parameters

Name Type Description
value AnnotationBorderStyle

The border style.

setCallout(AnnotationCallout value) Method

Sets the free text annotation callout.

Declaration

public void setCallout(AnnotationCallout value)

Parameters

Name Type Description
value AnnotationCallout

The callout.

setCalloutLineEndingStyle(AnnotationLineEndingStyle value) Method

Sets the free text annotation callout line ending style.

Declaration

public void setCalloutLineEndingStyle(AnnotationLineEndingStyle value)

Parameters

Name Type Description
value AnnotationLineEndingStyle

The line ending style that specifies the shape displayed at the end of an annotation line.

setDefaultStyle(String value) Method

Sets the free text annotation default style.

Declaration

public void setDefaultStyle(String value)

Parameters

Name Type Description
value String

The default style.

setFinishCalloutLineEndingStyle(AnnotationLineEndingStyle value) Method

Sets the free text annotation finish callout line ending style.

Declaration

public void setFinishCalloutLineEndingStyle(AnnotationLineEndingStyle value)

Parameters

Name Type Description
value AnnotationLineEndingStyle

The finish callout line ending style.

setFreeTextIntent(FreeTextAnnotationIntent value) Method

Sets the free text annotation intent.

Declaration

public void setFreeTextIntent(FreeTextAnnotationIntent value)

Parameters

Name Type Description
value FreeTextAnnotationIntent

The free text annotation intent.

setOutlineFill(Fill value) Method

Sets the free text annotation outline fill.

Declaration

public void setOutlineFill(Fill value)

Parameters

Name Type Description
value Fill

The outline fill.

setPadding(Padding value) Method

Sets the free text annotation padding.

Declaration

public void setPadding(Padding value)

Parameters

Name Type Description
value Padding

The padding.

setTextAppearance(TextAppearance value) Method

Sets the free text annotation text appearance.

Declaration

public void setTextAppearance(TextAppearance value)

Parameters

Name Type Description
value TextAppearance

The text appearance.

setTextJustification(TextJustification value) Method

Sets the free text annotation text justification.

Declaration

public void setTextJustification(TextJustification value)

Parameters

Name Type Description
value TextJustification

The text justification.