For the complete documentation index, see llms.txt. This page is also available as Markdown.

Customize annotation style properties

AnnotEdit tool class can edit the style of a selected annotation easily by using annotation style dialog . You can set AnnotEdit tool to ToolManager as described here: change tool mode .

With Apryse library, you can change annotation styles such as border color, border thickness, fill color, etc. To change annotation style, you must lock PDF document first. For more information about locking document, see: document locking.

Changing an annotation border thickness

To change an annotation border thickness:

  1. Get the BorderStyle from the annotation by calling annot.getBorderStyle().

  2. Set thickness to the BorderSytle by calling borderStyle.setWidth(double).

  3. Refresh the annotation appearance by calling annot.refreshAppearance().

  4. Update the PDFViewCtrl contents by calling pdfViewCtrl.update().

void changeAnnotThickness(final PDFViewCtrl pdfViewCtrl, final Annot annot, final double thickness) throws Exception {
    // Locks the document first as accessing annotation/doc
    // information isn't thread safe.
    pdfViewCtrl.docLock(true, new PDFViewCtrl.LockRunnable() {
        @Override
        public void run() throws Exception {
            Annot.BorderStyle borderStyle = annot.getBorderStyle();
            borderStyle.setWidth(thickness);

            annot.refreshAppearance();
            pdfViewCtrl.update();
        }
    });
}
fun changeAnnotThickness(pdfViewCtrl: PDFViewCtrl, annot: Annot, thickness: Double) { 
    // Locks the document first as accessing annotation/doc
    // information isn't thread safe.
    pdfViewCtrl.docLock(true) {
        val borderStyle = annot.borderStyle
        borderStyle.width = thickness
        annot.refreshAppearance()
        pdfViewCtrl.update()
    }
}

To make annotation border invisible, call borderStyle.setWidth(0).

Changing an annotation border color.

If there is a FreeText annotation, to set the border color of the annotation, call [freeText.setLineColor(ColorPt, int)](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/annots/FreeText.html#setLineColor(com.pdftron.pdf.ColorPt, int)). To set the border color of the other annotation types, call [annot.setColor(ColorPt, int)](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/Annot.html#setColor(com.pdftron.pdf.ColorPt, int)).

To set the color of a Text annotation, call annot.setColor(ColorPt, int).

Changing an annotation opacity

To change the opacity of a Markup annotation, callMarkup.setOpacity(double):

Changing an annotation fill color

To set the fill color of a Markup annotation, call [Markup.setInteriorColor(ColorPt, int)](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/annots/Markup.html#setInteriorColor(com.pdftron.pdf.ColorPt, int)).

Changing a Text annotation icon

To change a Text annotation icon, call Text.setIcon(String). After changing the icon, you must refresh the annotation appearance by calling [AnnotUtils.refreshStickyNoteAppearance(Annot, PDFViewCtrl)](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/utils/AnnotUtils.html#refreshStickyNoteAppearance(Annot, PDFViewCtrl)).

For available icons, see: default icons table .

Changing a FreeText annotation text color

To change the text color of a FreeText annotation, call [FreeText.setTextColor(ColorPt, int)](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/annots/FreeText.html#setTextColor(com.pdftron.pdf.ColorPt, int)).

Changing a FreeText annotation text size

To change the text size of a FreeText annotation, call FreeText.setFontSize(double).

Changing a FreeText annotation font

The follow code snippet shows how to set the font to a FreeText annotation:

Last updated

Was this helpful?