PDF viewer dark theme in Java for Kotlin
An example with applied custom theme. Get additional resources by visiting our guide on customizing PDF viewer styling 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 android.net.Uriimport com.pspdfkit.catalog.Rimport com.pspdfkit.catalog.SdkExampleimport com.pspdfkit.catalog.tasks.ExtractAssetTaskimport com.pspdfkit.configuration.activity.PdfActivityConfigurationimport com.pspdfkit.ui.PdfActivityimport com.pspdfkit.ui.PdfActivityIntentBuilder
/** * This example shows how to make [PdfActivity] use custom theme. */class DarkThemeExample(context: Context) : SdkExample(context, R.string.darkThemeExampleTitle, R.string.darkThemeExampleDescription) { override fun launchExample(context: Context, configuration: PdfActivityConfiguration.Builder) { // We use a custom utility class to extract the example document from the assets. ExtractAssetTask.extract(WELCOME_DOC, title, context) { documentFile ->
// You can set the custom theme directly through PdfActivity configuration. configuration.theme(R.style.PSPDFCatalog_Theme_Dark)
// Alternatively, you can also define theme on your custom activity directly in AndroidManifest.xml: // <activity // android:name="YourCustomActivity" // android:theme="@style/PSPDFCatalog.Theme.Dark" />
// To start the DarkThemeActivity create a launch intent using the PdfActivityIntentBuilder val intent = PdfActivityIntentBuilder.fromUri(context, Uri.fromFile(documentFile)) .configuration(configuration.build()) .build()
// Start the DarkThemeActivity for the extracted document. context.startActivity(intent) } }}
This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.