Hiding annotations on Android

By default, Nutrient will render all known annotation types. See AnnotationType for a full list of the available types.

Hiding specific annotation types

When building your PdfConfiguration, you have the ability to specify excludedAnnotationTypes. This allows you to exclude specific types from being rendered.

For example, to allow only highlights and drawings to be rendered, configure the document like this:

val configuration: PdfConfiguration = ...

// Create a list with all annotation types.
val excludedAnnotationTypes = ArrayList(EnumSet.allOf(AnnotationType::class.java))
// Then remove the ones you would like to display.
excludedAnnotationTypes.remove(AnnotationType.HIGHLIGHT)
excludedAnnotationTypes.remove(AnnotationType.INK)
// Apply this to your configuration.
configuration.excludedAnnotationTypes(excludedAnnotationTypes)
PdfConfiguration configuration = ...;

// Create a list with all annotation types.
ArrayList<AnnotationType> excludedAnnotationTypes = new ArrayList<>(EnumSet.allOf(AnnotationType.class));

// Then remove the ones you would like to display.
excludedAnnotationTypes.remove(AnnotationType.HIGHLIGHT);
excludedAnnotationTypes.remove(AnnotationType.INK);

// Apply this to your configuration.
configuration.excludedAnnotationTypes(excludedAnnotationTypes);

Or, to exclude only highlights and drawings, configure the document like this:

val configuration: PdfConfiguration = ...

// Excludes ink and stamps from being rendered.
configuration.excludedAnnotationTypes(ArrayList(EnumSet.of(AnnotationType.INK, AnnotationType.HIGHLIGHT)))
PdfConfiguration configuration = ...;

// Excludes ink and stamps from being rendered.
configuration.excludedAnnotationTypes(new ArrayList<>(EnumSet.of(AnnotationType.INK, AnnotationType.HIGHLIGHT)));

You need to configure this before creating the PdfFragment. If you are using a PdfActivity, you can update it using setConfiguration().

Including and excluding all annotation types

You can also exclude all annotation types by passing in all types:

val configuration: PdfConfiguration = ...

// Passing all annotation types will exclude all annotations from being rendered.
configuration.excludedAnnotationTypes(ArrayList(EnumSet.allOf(AnnotationType::class.java)))
PdfConfiguration configuration = ...;

// Passing all annotation types will exclude all annotations from being rendered.
configuration.excludedAnnotationTypes(new ArrayList<>(EnumSet.allOf(AnnotationType.class)));

And to include them, pass in an empty array:

val configuration: PdfConfiguration = ...

// Passing an empty list will render all annotations.
configuration.excludedAnnotationTypes(ArrayList())
PdfConfiguration configuration = ...;

// Passing an empty list will render all annotations.
configuration.excludedAnnotationTypes(new ArrayList<>());