Skip to content

Commit d757d3b

Browse files
committed
ComPDFKit V1.13.0
1 parent a84b988 commit d757d3b

20 files changed

+441
-1492
lines changed

README.md

Lines changed: 123 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ target 'PDFView_RN' do
131131
# Pods for testing
132132
end
133133

134-
+ pod 'ComPDFKit_Tools', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/1.12.0.podspec'
135-
+ pod 'ComPDFKit', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/1.12.0.podspec'
134+
+ pod 'ComPDFKit_Tools', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/1.13.0.podspec'
135+
+ pod 'ComPDFKit', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/1.13.0.podspec'
136136

137137
# Enables Flipper.
138138
#
@@ -220,9 +220,9 @@ open android/app/build.gradle
220220
```diff
221221
dependencies {
222222
...
223-
+ implementation 'com.compdf:compdfkit:1.12.0'
224-
+ implementation 'com.compdf:compdfkit-ui:1.12.0'
225-
+ implementation 'com.compdf:compdfkit-tools:1.12.0'
223+
+ implementation 'com.compdf:compdfkit:1.13.0'
224+
+ implementation 'com.compdf:compdfkit-ui:1.13.0'
225+
+ implementation 'com.compdf:compdfkit-tools:1.13.0'
226226
}
227227
```
228228

@@ -234,12 +234,14 @@ dependencies {
234234
-keep class com.compdfkit.tools.** {*;}
235235
```
236236

237-
6. open **android/app/src/main/AndroidManifest.xml** , add `ComPDFKit License` and `Storage Permission`:
237+
6. open **android/app/src/main/AndroidManifest.xml** , add `Internet Permission` and `Storage Permission`:
238238

239239
```diff
240240
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
241241
package="com.compdfkit.flutter.example">
242242

243+
+ <uses-permission android:name="android.permission.INTERNET"/>
244+
243245
<!-- Required to read and write documents from device storage -->
244246
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
245247
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
@@ -249,11 +251,6 @@ dependencies {
249251
+ android:requestLegacyExternalStorage="true"
250252
...>
251253
...
252-
<!-- Please replace it with your ComPDFKit license -->
253-
+ <meta-data
254-
+ android:name="compdfkit_key"
255-
+ android:value="{your license key}" />
256-
...
257254
</application>
258255
</manifest>
259256
```
@@ -282,31 +279,14 @@ protected List<ReactPackage> getPackages() {
282279

283280
#### For iOS
284281

285-
1. Import the header file ***"ComPDFKit/ComPDFKit.h"*** to `AppDelegate.m`.
286-
287-
2. Follow the code below and call the method `CPDFKit verifyWithKey:@"LICENSE_KEY"` in `- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions`. You need to replace the **LICENSE_KEY** with the license you obtained.
288-
289-
```objc
290-
#import <ComPDFKit/ComPDFKit.h>
291-
292-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
293-
// Set your license key here. ComPDFKit is commercial software.
294-
// Each ComPDFKit license is bound to a specific app bundle id.
295-
// com.compdfkit.pdfviewer
296-
297-
[CPDFKit verifyWithKey:@"YOUR_LICENSE_KEY_GOES_HERE"];
298-
299-
return YES;
300-
}
301-
```
282+
1. Open your project's Podfile in a text editor:
302283

303-
3. Open your project's Podfile in a text editor:
304284

305285
```bash
306286
open ios/Podfile
307287
```
308288

309-
4. Update the platform to iOS 11 and add the ComPDFKit Podspec:
289+
2. Update the platform to iOS 11 and add the ComPDFKit Podspec:
310290

311291
```diff
312292
require_relative '../node_modules/react-native/scripts/react_native_pods'
@@ -336,8 +316,8 @@ target 'PDFView_RN' do
336316
# Pods for testing
337317
end
338318

339-
+ pod 'ComPDFKit_Tools', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/1.12.0.podspec'
340-
+ pod 'ComPDFKit', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/1.12.0.podspec'
319+
+ pod 'ComPDFKit_Tools', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit_tools/1.13.0.podspec'
320+
+ pod 'ComPDFKit', podspec:'https://www.compdf.com/download/ios/cocoapods/xcframeworks/compdfkit/1.13.0.podspec'
341321

342322
# Enables Flipper.
343323
#
@@ -352,35 +332,37 @@ target 'PDFView_RN' do
352332
end
353333
```
354334

355-
5. Go to the **compdfkit_rn/ios** folder and run the `pod install` command:
335+
3. Go to the **compdfkit_rn/ios** folder and run the `pod install` command:
356336

357337
```bash
358338
pod install
359339
```
360340

361-
6. Open your project's Workspace in Xcode:
341+
**Note:** If SSL network requests fail to download the `ComPDFKit` library when you run `pod install`, you can see the processing method in [Troubleshooting](#Troubleshooting).
342+
343+
4. Open your project's Workspace in Xcode:
362344

363345
```bash
364346
open ios/PDFView_RN.xcworkspace
365347
```
366348

367-
7. Make sure the deployment target is set to 10.0 or higher:
349+
5. Make sure the deployment target is set to 10.0 or higher:
368350

369351
<img src="Image/1-1.png" width="80%" height="80%"/>
370352

371-
8. Import resource file,***"OpenPDFModule.swift"*** is the bridging file for connecting React Native to the iOS native module.
353+
6. Import resource file,***"OpenPDFModule.swift"*** is the bridging file for connecting React Native to the iOS native module.
372354

373355
<img src="Image/1-2.png" alt="1-2" width="80%" height="80%"/>
374356

375-
9. Search for **bridging** in the **Build Settings** and locate the **Objective-C Bridging Header** option. Then, enter the file path of the header file ***"ComPDFKit_RN-Bridging-Header.h"***:
357+
7. Search for **bridging** in the **Build Settings** and locate the **Objective-C Bridging Header** option. Then, enter the file path of the header file ***"ComPDFKit_RN-Bridging-Header.h"***:
376358

377359
<img src="Image/1-9.png" alt="1-9" width="80%" height="80%"/>
378360

379-
10. 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 "developer_guide_ios.pdf" as an example.
361+
8. 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 "developer_guide_ios.pdf" as an example.
380362

381363
<img src="Image/1-7.png" width="80%" height="80%" />
382364

383-
11. To protect user privacy, before accessing the sensitive privacy data, you need to find the ***"Info"*** configuration in your iOS 10.0 or higher iOS project and configure the relevant privacy terms as shown in the following picture.
365+
9. To protect user privacy, before accessing the sensitive privacy data, you need to find the ***"Info"*** configuration in your iOS 10.0 or higher iOS project and configure the relevant privacy terms as shown in the following picture.
384366

385367
<img src="Image/1-8.png" width="80%" height="80%" />
386368

@@ -396,9 +378,49 @@ open ios/PDFView_RN.xcworkspace
396378

397379
<key>NSPhotoLibraryUsageDescription</key>
398380
<string>Your consent is required before you could access the function.</string>
381+
382+
<key>NSAppTransportSecurity</key>
383+
<dict>
384+
<key>NSAllowsArbitraryLoads</key>
385+
<true/>
386+
</dict>
399387
```
400388

389+
### Apply the License Key
390+
391+
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.
392+
393+
To initialize ComPDFKit using a license key, call either of the following before using any other ComPDFKit APIs or features:
401394

395+
* **Online license**
396+
397+
```tsx
398+
type Props = {};
399+
export default class App extends Component<Props> {
400+
...
401+
402+
componentDidMount(){
403+
// Fill in your online license
404+
NativeModules.OpenPDFModule.initialize('your android platform compdfkit license', 'your ios platform compdfkit license')
405+
}
406+
// ...
407+
}
408+
```
409+
410+
* **Offline license**
411+
412+
```tsx
413+
type Props = {};
414+
export default class App extends Component<Props> {
415+
...
416+
417+
componentDidMount(){
418+
// Fill in your offline license
419+
NativeModules.OpenPDFModule.init_('your compdfkit license')
420+
}
421+
// ...
422+
}
423+
```
402424

403425
### Run Project
404426

@@ -447,6 +469,15 @@ const instructions = Platform.select({
447469

448470
type Props = {};
449471
export default class App extends Component<Props> {
472+
473+
componentDidMount(){
474+
// Fill in your online license
475+
NativeModules.OpenPDFModule.initialize('your android platform compdfkit license', 'your ios platform compdfkit license')
476+
477+
// Fill in your offline license
478+
// NativeModules.OpenPDFModule.init_('your compdfkit license')
479+
}
480+
450481
render() {
451482
return (
452483
<View style={styles.container}>
@@ -543,6 +574,7 @@ Showing a PDF document inside your React-Native app is as simple as this:
543574
NativeModules.OpenPDFModule.openPDF(JSON.stringify(configuration))
544575

545576
// Open the document in the specified path
577+
// The ios platform can use this method to pass in the url string
546578
NativeModules.OpenPDFModule.openPDFByConfiguration(String filePath, String password, String configuration)
547579

548580
// Opening a document using Uri on the Android platform.
@@ -551,6 +583,58 @@ NativeModules.OpenPDFModule.openPDFByUri(String uriString, String password, Stri
551583

552584

553585

586+
## Troubleshooting
587+
588+
1.SSL network request to download 'ComPDFKit' library failed when cocopods downloaded iOS third-party library
589+
590+
If SSL network requests fail to download the `ComPDFKit` library when you run `pod install`, replace the third-party platform download address link of the ComPDFKit library and execute `pod install`
591+
592+
```diff
593+
require_relative '../node_modules/react-native/scripts/react_native_pods'
594+
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
595+
596+
- platform :ios, '10.0'
597+
+ platform :ios, '11.0'
598+
install! 'cocoapods', :deterministic_uuids => false
599+
600+
target 'PDFView_RN' do
601+
config = use_native_modules!
602+
603+
# Flags change depending on the env values.
604+
flags = get_default_flags()
605+
606+
use_react_native!(
607+
:path => config[:reactNativePath],
608+
# to enable hermes on iOS, change `false` to `true` and then install pods
609+
:hermes_enabled => flags[:hermes_enabled],
610+
:fabric_enabled => flags[:fabric_enabled],
611+
# An absolute path to your application root.
612+
:app_path => "#{Pod::Config.instance.installation_root}/.."
613+
)
614+
615+
target 'PDFView_RNTests' do
616+
inherit! :complete
617+
# Pods for testing
618+
end
619+
620+
+ pod 'ComPDFKit', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '1.13.0'
621+
+ pod 'ComPDFKit_Tools', :git => 'https://github.com/ComPDFKit/compdfkit-pdf-sdk-ios-swift.git', :tag => '1.13.0'
622+
623+
# Enables Flipper.
624+
#
625+
# Note that if you have use_frameworks! enabled, Flipper will not work and
626+
# you should disable the next line.
627+
use_flipper!()
628+
629+
post_install do |installer|
630+
react_native_post_install(installer)
631+
__apply_Xcode_12_5_M1_post_install_workaround(installer)
632+
end
633+
end
634+
```
635+
636+
637+
554638
## Support
555639

556640
[ComPDFKit](https://www.compdf.com/) has a professional R&D team that produces comprehensive technical documentation and guides to help developers. Also, you can get an immediate response when reporting your problems to our support team.

example/App.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ const instructions = Platform.select({
3030

3131
type Props = {};
3232
export default class App extends Component<Props> {
33+
34+
componentDidMount(){
35+
// offline auth
36+
NativeModules.OpenPDFModule.init_('your compdfkit key')
37+
}
38+
3339
render() {
3440
return (
3541
<View style={styles.container}>

0 commit comments

Comments
 (0)