|
@@ -94,43 +94,7 @@ ComPDFKit for React Native is a commercial SDK, which requires a license to gran
|
|
|
|
|
|
To initialize ComPDFKit using a license key, call either of the following before using any other ComPDFKit APIs or features:
|
|
|
|
|
|
-To set the license key for Android , use:
|
|
|
|
|
|
-* **Offline license**
|
|
|
-
|
|
|
-```xml
|
|
|
-<!-- Add this license in the AndroidManifest.xml of the main module --/>
|
|
|
-<!-- Each ComPDFKit license is bound to a specific applicationId -->
|
|
|
-<!-- For example: com.compdfkit.pdfviewer -->
|
|
|
-<meta-data
|
|
|
- android:name="compdfkit_key"
|
|
|
- android:value="Your ComPDFKit Key" />
|
|
|
-
|
|
|
-<meta-data
|
|
|
- android:name="compdfkit_offline"
|
|
|
- android:value="true" />
|
|
|
-```
|
|
|
-
|
|
|
-* **Online license**
|
|
|
-
|
|
|
-```xml
|
|
|
-<!-- Add this license in the AndroidManifest.xml of the main module --/>
|
|
|
-<!-- Each ComPDFKit license is bound to a specific applicationId -->
|
|
|
-<!-- For example: com.compdfkit.pdfviewer -->
|
|
|
-<meta-data
|
|
|
- android:name="compdfkit_key"
|
|
|
- android:value="Your ComPDFKit Key" />
|
|
|
-```
|
|
|
-
|
|
|
-To set the license key for iOS, use:
|
|
|
-
|
|
|
-```objective-c
|
|
|
-// Set your license key here. ComPDFKit is commercial software.
|
|
|
- // Each ComPDFKit license is bound to a specific app bundle id.
|
|
|
- // com.compdfkit.pdfviewer
|
|
|
-
|
|
|
- [CPDFKit verifyWithKey:@"YOUR_LICENSE_KEY_GOES_HERE"];
|
|
|
-```
|
|
|
|
|
|
# 2 Get Started
|
|
|
|
|
@@ -189,7 +153,7 @@ Let's create a simple app that integrates ComPDFKit for React Native.
|
|
|
```
|
|
|
4. Add the ComPDFKit library and import the presented PDF document.
|
|
|
|
|
|
-### For Android
|
|
|
+### 2.2.1 For Android
|
|
|
|
|
|
Open the `android/build.gradle` file located in the project root directory and add the `mavenCentral` repository:
|
|
|
|
|
@@ -229,7 +193,7 @@ dependencies {
|
|
|
}
|
|
|
```
|
|
|
|
|
|
-open `android/app/src/main/AndroidManifest.xml` , add`ComPDFKit License` and `Storage Permission`:
|
|
|
+open `android/app/src/main/AndroidManifest.xml` , add `Storage Permission`:
|
|
|
|
|
|
```diff
|
|
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
@@ -244,16 +208,6 @@ open `android/app/src/main/AndroidManifest.xml` , add`ComPDFKit License` and `S
|
|
|
+ android:requestLegacyExternalStorage="true"
|
|
|
...>
|
|
|
...
|
|
|
- <!-- Please replace it with your ComPDFKit license -->
|
|
|
-+ <meta-data
|
|
|
-+ android:name="compdfkit_key"
|
|
|
-+ android:value="{your license key}" />
|
|
|
-
|
|
|
- <!-- If you are using an offline authentication license, please set the code. -->
|
|
|
-+ <meta-data
|
|
|
-+ android:name="compdfkit_offline"
|
|
|
-+ android:value="true"/>
|
|
|
- ...
|
|
|
</application>
|
|
|
</manifest>
|
|
|
```
|
|
@@ -278,7 +232,7 @@ Copy the sample pdf file to the `assets` directory
|
|
|
|
|
|
<img src="./Image/1-6.png" alt="1-6" style="zoom:33%;" />
|
|
|
|
|
|
-### For iOS
|
|
|
+### 2.2.2 For iOS
|
|
|
|
|
|
Open your project’s Podfile in a text editor:
|
|
|
|
|
@@ -378,7 +332,45 @@ To protect user privacy, before accessing the sensitive privacy data, you need t
|
|
|
<string>Your consent is required before you could access the function.</string>
|
|
|
```
|
|
|
|
|
|
-## 2.3 Run Project
|
|
|
+
|
|
|
+
|
|
|
+## 2.3 Apply the License Key
|
|
|
+
|
|
|
+ComPDFKit for React Native is a commercial SDK, which requires a license to grant developer permission to release their apps. Each license is only valid for one `bundle ID` or `applicationId` in development mode. Other flexible licensing options are also supported, please contact [our marketing team](mailto:support@compdf.com) to know more.
|
|
|
+
|
|
|
+To initialize ComPDFKit using a license key, call either of the following before using any other ComPDFKit APIs or features:
|
|
|
+
|
|
|
+* **Online license**
|
|
|
+
|
|
|
+```tsx
|
|
|
+type Props = {};
|
|
|
+export default class App extends Component<Props> {
|
|
|
+ ...
|
|
|
+
|
|
|
+ componentDidMount(){
|
|
|
+ NativeModules.OpenPDFModule.initialize('your android platform compdfkit license', 'your ios platform compdfkit license')
|
|
|
+ }
|
|
|
+ // ...
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+* **Offline license**
|
|
|
+
|
|
|
+```tsx
|
|
|
+type Props = {};
|
|
|
+export default class App extends Component<Props> {
|
|
|
+ ...
|
|
|
+
|
|
|
+ componentDidMount(){
|
|
|
+ NativeModules.OpenPDFModule.init('your compdfkit license')
|
|
|
+ }
|
|
|
+ // ...
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+## 2.4 Run Project
|
|
|
|
|
|
1. Create an `assets` directory in the project's root directory and copy the **[configuration.json](./assets/configuration.json)** file from the demo to this directory.
|
|
|
|
|
@@ -425,6 +417,15 @@ const instructions = Platform.select({
|
|
|
|
|
|
type Props = {};
|
|
|
export default class App extends Component<Props> {
|
|
|
+
|
|
|
+ componentDidMount(){
|
|
|
+ // Fill in your offline license
|
|
|
+ NativeModules.OpenPDFModule.initialize('your android platform compdfkit license', 'your ios platform compdfkit license')
|
|
|
+
|
|
|
+ // Fill in your online license
|
|
|
+ // NativeModules.OpenPDFModule.init('your compdfkit license')
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
@@ -498,17 +499,24 @@ const styles = StyleSheet.create({
|
|
|
});
|
|
|
```
|
|
|
|
|
|
-7. We have provided two quick ways to open PDFs:
|
|
|
+4. The app is now ready to launch! Go back to the terminal.
|
|
|
|
|
|
-- Open the default document directly
|
|
|
+```bash
|
|
|
+//Run on Android devices
|
|
|
+npx react-native run-android
|
|
|
|
|
|
-```tsx
|
|
|
-NativeModules.OpenPDFModule.openPDF(JSON.stringify(configuration))
|
|
|
+//Run on iOS devices
|
|
|
+npx react-native run-ios
|
|
|
```
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+We have provided two quick ways to open PDFs:
|
|
|
+
|
|
|
- Open the document in the specified path
|
|
|
|
|
|
```tsx
|
|
|
+// The ios platform can use this method to pass in the url string
|
|
|
NativeModules.OpenPDFModule.openPDFByConfiguration(String filePath, String password, String configuration)
|
|
|
```
|
|
|
|
|
@@ -518,16 +526,6 @@ NativeModules.OpenPDFModule.openPDFByConfiguration(String filePath, String passw
|
|
|
NativeModules.OpenPDFModule.openPDFByUri(String uriString, String password, String configuration)
|
|
|
```
|
|
|
|
|
|
-The app is now ready to launch! Go back to the terminal.
|
|
|
-
|
|
|
-```bash
|
|
|
-//Run on Android devices
|
|
|
-npx react-native run-android
|
|
|
-
|
|
|
-//Run on iOS devices
|
|
|
-npx react-native run-ios
|
|
|
-```
|
|
|
-
|
|
|
|
|
|
|
|
|
# 3 UI Customization
|