This guide covers the shortest supported path from installation to a working PDF reader. Use the generated API reference for complete signatures and the available options for each method.
The examples focus on the public React Native integration surface.
npm install @compdfkit_pdf_sdk/react_native
For Expo, add the SDK config plugin and create a development build. For React Native CLI, install the native dependencies and run the normal iOS and Android native setup steps.
The SDK requires Android minSdkVersion 21+ and iOS 12+.
android/app/src/main/assets/.Use the platform-specific license path format documented on
ComPDFKit.initWithPath.
Initialize the SDK before rendering CPDFReaderView:
import React, { useEffect } from "react";
import { Platform, SafeAreaView } from "react-native";
import {
ComPDFKit,
CPDFReaderView,
} from "@compdfkit_pdf_sdk/react_native";
export default function PdfScreen() {
useEffect(() => {
void ComPDFKit.initWithPath(
Platform.OS === "android"
? "assets://license_key_rn.xml"
: "license_key_rn.xml",
);
}, []);
const document = Platform.OS === "android"
? "file:///android_asset/PDF_Document.pdf"
: "PDF_Document.pdf";
return (
<SafeAreaView style={{ flex: 1 }}>
<CPDFReaderView
document={document}
configuration={ComPDFKit.getDefaultConfig({})}
style={{ flex: 1 }}
/>
</SafeAreaView>
);
}
Pass overrides to ComPDFKit.getDefaultConfig instead of rebuilding the full
configuration object. This keeps platform defaults and limits the amount of
configuration that must be maintained by the application.
const configuration = ComPDFKit.getDefaultConfig({
modeConfig: {
initialViewMode: "viewer",
availableViewModes: ["viewer", "annotations"],
},
toolbarConfig: {
annotationToolbarVisible: true,
contentEditorToolbarVisible: false,
},
});
CPDFReaderView for rendering, reader state, events, and view settings.CPDFDocument for document-wide operations and saving.CPDFPage for page text, annotations, and form widgets.Some reader operations are platform-specific. Check the method's Remarks and
Throws sections before using view settings or file operations in shared code.
When a method is Android-only or iOS-only, guard it with Platform.OS and
provide a fallback for the other platform.
getDefaultConfig.