Render PDF annotation in Kotlin for Android
Having complete control over annotation rendering mean you can render only a custom set of annotations of a document. Get additional resources by visiting our guide on rendering annotations in Android.
/* * Copyright © 2020-2025 PSPDFKit GmbH. All rights reserved. * * The PSPDFKit Sample applications are licensed with a modified BSD license. * Please see License for details. This notice may not be removed from this file. */
package com.pspdfkit.catalog.examples.kotlin
import android.content.Contextimport com.pspdfkit.annotations.AnnotationTypeimport com.pspdfkit.catalog.Rimport com.pspdfkit.configuration.activity.PdfActivityConfiguration
/** * This example shows how to configure [com.pspdfkit.ui.PdfActivity] to only render a custom set of annotation types. */class AnnotationRenderingExample(context: Context) : AssetExample(context, R.string.annotationRenderingExampleTitle, R.string.annotationRenderingExampleDescription) {
override val assetPath: String = ANNOTATIONS_EXAMPLE
override fun prepareConfiguration(configuration: PdfActivityConfiguration.Builder) { // List of annotation types that should be excluded from rendering can be set via configuration. configuration.excludedAnnotationTypes(listOf(AnnotationType.NOTE, AnnotationType.HIGHLIGHT)) }}
This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.