Customize annotation style properties
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:
Get the
BorderStylefrom the annotation by callingannot.getBorderStyle().Set thickness to the
BorderSytleby callingborderStyle.setWidth(double).Refresh the annotation appearance by calling
annot.refreshAppearance().Update the
PDFViewCtrlcontents by callingpdfViewCtrl.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()
}
}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)).
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)).
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?