Readium Adapter for PSPDFKit
PSPDFKit is a commercial library for rendering PDF documents. This adapter provides an implementation of Readium's PdfDocument
for parsing a PDF publication, and of PdfDocumentFragment
to render a PDF with PdfNavigatorFragment
. LCP protected PDFs are fully supported.
If you are looking for a free, open source PDF adapter, take a look at PdfiumAndroid.
Follow the same setup instructions as the core Readium toolkit, then add this new dependency in your app's build.gradle
.
dependencies {
implementation "org.readium.kotlin-toolkit:readium-adapter-pspdfkit:$readium_version"
// Or, if you need only the parser but not the navigator:
implementation "org.readium.kotlin-toolkit:readium-adapter-pspdfkit-document:$readium_version"
}
This adapter requires PSPDFKit's maven repository in your root build.gradle
:
allprojects {
repositories {
maven { url "https://customers.pspdfkit.com/maven" }
}
}
Finally, follow PSPDFKit's instructions to add your license key in your app's AndroidManifest.xml
.
To open a PDF publication with PSPDFKit, initialize the Streamer
with the adapter factory:
val streamer = Streamer(context,
pdfFactory = PsPdfKitDocumentFactory(context)
)
val publication = streamer.open(FileAsset(pdfFile)).getOrThrow()
To render the PDF using Readium's PdfNavigatorFragment
, instantiate PsPdfKitEngineProvider
and use the PdfNavigatorFactory
to get a FragmentFactory
and a PreferencesEditor
.