Skip to content
DemoAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Installing the ComPDF Dependency ​

This guide uses 3.2.0. Keep the React Native package and native dependencies on the same version. You can integrate the SDK in two ways:

  • Through ComPDF GitHub repo:

    In MyApp folder, install @compdfkit_pdf_sdk/react_native by calling:

    shell
    yarn add github:ComPDFKit/compdfkit-pdf-sdk-react-native
  • Through ComPDF npm package:

    In MyApp folder, install run the following commands:

    shell
    yarn add @compdfkit_pdf_sdk/[email protected]

Android ​

Configure the host minimum version according to System Requirements. The ComPDF native baseline is API 23, but the application must also meet the selected RN version's requirement. The current RN 0.85.3 example uses minSdkVersion = 24.

  1. Open android/app/src/main/AndroidManifest.xml , add Internet Permission and Storage Permission:
diff
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">

+    <uses-permission android:name="android.permission.INTERNET"/>
  
    <!-- Required to read and write documents from device storage -->
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <!-- Optional settings -->
+    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

    <application
+    android:requestLegacyExternalStorage="true"
        ...>
  ...
    </application>
</manifest>
  1. Copy the sample pdf file to the assets directory
demo-android-2
  1. Replace App.js (or App.tsx) with what is shown for Usage Example

  2. Finally in the root project directory, run react-native run-android.

iOS ​

  1. Open your project’s Podfile in a text editor:
bash
open ios/Podfile
  1. Add the following line to the target 'MyApp' do ... end block:
diff
target 'MyApp' do
    # ...
+  pod "ComPDFKit", podspec:'https://file.compdf.com/cocoapods/ios/compdfkit_pdf_sdk/3.2.0/ComPDFKit.podspec'
+  pod "ComPDFKit_Tools", podspec:'https://file.compdf.com/cocoapods/ios/compdfkit_pdf_sdk/3.2.0/ComPDFKit_Tools.podspec'
    # ...
end

Note: If SSL network requests fail to download the ComPDF library when you run pod install, you can use the following method instead.

diff
target 'MyApp' do
    # ...
+  pod 'ComPDFKit', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '3.2.0'
+  pod 'ComPDFKit_Tools', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '3.2.0'
    # ...
end
  1. In the ios folder, run pod install.

  2. Open your project’s Workspace in Xcode:

    bash
    open ios/MyApp.xcworkspace

    Configure the deployment target according to System Requirements. The ComPDF native baseline is iOS 13.0, but the application must also meet the selected RN version's requirement. The current RN 0.85.3 example uses iOS 15.1. The Podfile can retain the RN template's min_ios_version_supported; keep the application Target consistent.

  3. Add the PDF document you want to display to your application by dragging it into your project. On the dialog that’s displayed, select Finish to accept the default integration options. You can use "PDF_Document.pdf" as an example.

demo-android-1-7
xml
<key>NSCameraUsageDescription</key>
<string>Your consent is required before you could access the function.</string>

<key>NSMicrophoneUsageDescription</key>
<string>Your consent is required before you could access the function.</string>

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Your consent is required before you could access the function.</string>

<key>NSPhotoLibraryUsageDescription</key>
<string>Your consent is required before you could access the function.</string>
  
<key>NSAppTransportSecurity</key>
  <dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
  </dict>
  1. Replace App.js (or App.tsx) with what is shown for Usage Example

  2. Finally in the root project directory, run react-native run-ios.