pspdfkit-cordova
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -9,23 +9,142 @@ # Cordova Plugin - PSPDFKit for Android 6 | ||
## Requirements | ||
- Android SDK API level 19+ / Android 4.4+ (KitKat) | ||
- Cordova Android 8+. | ||
- PSPDFKit for Android 6.5.3 | ||
## Cordova Requirements | ||
## Installation | ||
- The [latest stable version of cordova-lib](https://github.com/apache/cordova-lib/releases). | ||
- The [latest stable version of cordova-android](https://github.com/apache/cordova-android/releases). | ||
- The [Java 8 Development Kit](https://www.oracle.com/ca-en/java/technologies/javase/javase-jdk8-downloads.html). | ||
- The [latest stable version of Android Studio](https://developer.android.com/studio). | ||
- The [Android NDK](https://developer.android.com/studio/projects/install-ndk). | ||
- The [latest stable version of Gradle](https://gradle.org/install). | ||
- An [Android Virtual Device](https://developer.android.com/studio/run/managing-avds.html) or a hardware device. | ||
## Ionic Requirements | ||
- A [development environment setup](https://ionicframework.com/getting-started/) for running Ionic projects. | ||
- The [latest stable version of Node.js](https://nodejs.org/en/). | ||
- The [latest stable version of Ionic CLI](https://ionicframework.com/docs/cli). | ||
- The [latest stable version of `cordova-res`](https://www.npmjs.com/package/cordova-res). | ||
- The [Java 8 Development Kit](https://www.oracle.com/ca-en/java/technologies/javase/javase-jdk8-downloads.html). | ||
- The [latest stable version of Android Studio](https://developer.android.com/studio). | ||
- The [Android NDK](https://developer.android.com/studio/projects/install-ndk). | ||
- The [latest stable version of Gradle](https://gradle.org/install). | ||
- An [Android Virtual Device](https://developer.android.com/studio/run/managing-avds.html) or a hardware device. | ||
For more information regarding the Ionic installation you can check out the [official Ionic installation guide](https://ionicframework.com/docs/v1/guide/installation.html). | ||
## Cordova Installation | ||
We assume that you have [an existing Cordova project](https://cordova.apache.org/#getstarted). | ||
### Installation in a Cordova app | ||
1. Open the Terminal app and change the location of the current working directory inside the newly created project: | ||
```shell | ||
```bash | ||
cd path/to/YourProject | ||
``` | ||
2. Remove all the platforms from your project to properly propagate the changes in the `config.xml` file below throughout the project: | ||
```bash | ||
cordova platform remove android | ||
cordova platform remove ios | ||
``` | ||
3. Open `config.xml` in a text editor to enable AndroidX and to change the deployment target to iOS 12 or later: | ||
```bash | ||
open config.xml | ||
``` | ||
Your `config.xml` file should look like this: | ||
```diff | ||
... | ||
<platform name="android"> | ||
+ <preference name="AndroidXEnabled" value="true" /> | ||
<allow-intent href="market:*" /> | ||
</platform> | ||
<platform name="ios"> | ||
<allow-intent href="itms:*" /> | ||
<allow-intent href="itms-apps:*" /> | ||
+ <preference name="deployment-target" value="12.0" /> | ||
... | ||
</platform> | ||
... | ||
``` | ||
4. Add the PSPDFKit plugin: | ||
```bash | ||
cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git | ||
``` | ||
### Installation in an Ionic app | ||
5. Add back all the platforms: | ||
```shell | ||
```bash | ||
cordova platform add android | ||
cordova platform add ios | ||
``` | ||
## Ionic Installation | ||
We assume that you have [an existing Ionic project](https://ionicframework.com/docs/cli/start/). | ||
1. Open the Terminal app and change the location of the current working directory inside the newly created project: | ||
```bash | ||
cd path/to/YourProject | ||
``` | ||
2. Remove all the platforms from your project to properly propagate the changes in the `config.xml` file below throughout the project: | ||
```bash | ||
ionic cordova platform remove android | ||
ionic cordova platform remove ios | ||
``` | ||
3. Open `config.xml` in a text editor to enable AndroidX and to change the deployment target to iOS 12 or later: | ||
```bash | ||
open config.xml | ||
``` | ||
Your `config.xml` file should look like this: | ||
```diff | ||
... | ||
<platform name="android"> | ||
- <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
- <application android:networkSecurityConfig="@xml/network_security_config" /> | ||
- </edit-config> | ||
+ <preference name="AndroidXEnabled" value="true" /> | ||
... | ||
</platform> | ||
<platform name="ios"> | ||
<allow-intent href="itms:*" /> | ||
<allow-intent href="itms-apps:*" /> | ||
+ <allow-navigation href="*" /> | ||
+ <preference name="deployment-target" value="12.0" /> | ||
... | ||
</platform> | ||
... | ||
``` | ||
4. Add back all the platforms: | ||
```bash | ||
ionic cordova platform add android | ||
ionic cordova platform add ios | ||
``` | ||
5. Add the PSPDFKit plugin: | ||
```bash | ||
ionic cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git | ||
``` | ||
6. Declare PSPDFKit in the src/declarations.d.ts file: | ||
```shell | ||
echo "declare var PSPDFKit: any;" >> src/declarations.d.ts | ||
``` | ||
## Usage | ||
@@ -35,3 +154,2 @@ | ||
```javascript | ||
@@ -45,3 +163,3 @@ function showMyDocument() { | ||
useImmersiveMode: true, | ||
password: "my-document-password" | ||
password: "my-document-password", | ||
}); | ||
@@ -131,3 +249,3 @@ } | ||
Let's create a simple Corodva app that integrates PSPDFKit and uses the `pspdfkit-cordova` plugin. | ||
Let's create a minimal Corodva app that integrates PSPDFKit and uses the `pspdfkit-cordova` plugin. | ||
@@ -145,10 +263,27 @@ ### Quickstart Guide Cordova | ||
2. Add Android platform support to your project. This plugin requires the latest `android` plugin 8+. | ||
3. Open `config.xml` in a text editor to enable AndroidX and to change the deployment target to iOS 12 or later: | ||
```shell | ||
cordova platform add android | ||
```bash | ||
open config.xml | ||
``` | ||
3. Install the PSPDFKit plugin: | ||
Your `config.xml` file should look like this: | ||
```diff | ||
... | ||
<platform name="android"> | ||
+ <preference name="AndroidXEnabled" value="true" /> | ||
<allow-intent href="market:*" /> | ||
</platform> | ||
<platform name="ios"> | ||
<allow-intent href="itms:*" /> | ||
<allow-intent href="itms-apps:*" /> | ||
+ <preference name="deployment-target" value="12.0" /> | ||
... | ||
</platform> | ||
... | ||
``` | ||
2. Install the PSPDFKit plugin: | ||
```shell | ||
@@ -158,28 +293,26 @@ cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git | ||
4. Next you need to setup your PSPDFKit license key. If you don't have a license key yet, you can get one by requesting an evaluation version of PSPDFKit at https://pspdfkit.com/try. Inside your Android app's `platforms/android/local.properties` file, specify the `pspdfkit.license` property: | ||
3. Add Android platform support to your project. This plugin requires the latest `android` plugin 8+. | ||
```properties | ||
# This is the LICENSE_KEY you received when requesting a demo or from the customer portal. | ||
pspdfkit.license=LICENSE_STRING | ||
```shell | ||
cordova platform add android | ||
``` | ||
4. Next, you need to setup your PSPDFKit license key. If you don't have a license key yet, you can get one by requesting an evaluation version of PSPDFKit at https://pspdfkit.com/try. Inside your Android app's `platforms/android/local.properties` file, specify the `pspdfkit.license` property: | ||
> Note: If you're already a customer then please make sure that the package ID matches with your bundle ID that's assigned to your license (e.g. com.ionic.test). You can check this in your `AndroidManifest.xml` by searching for `package`. If you are using a trial license then you don't have to worry about that. | ||
```shell | ||
echo "pspdfkit.license=LICENSE_KEY_GOES_HERE" >> platforms/android/local.properties | ||
``` | ||
5. PSPDFKit requires modern Jetpack libraries AndroidX. To enable AndroidX modify the `config.xml` adding the following line in the `android` section: | ||
> Note: If you're already a customer then please make sure that the package ID matches with your bundle ID that's assigned to your license (e.g. com.example.pdfapp). You can check this in your `AndroidManifest.xml` by searching for `package`. If you are using a trial license then you don't have to worry about that. | ||
```diff | ||
... | ||
<platform name="android"> | ||
+ <preference name="AndroidXEnabled" value="true" /> | ||
<allow-intent href="market:*" /> | ||
</platform> | ||
... | ||
5. Add the PDF document you want to display in your project’s `assets` directory. You can use <a href="https://pspdfkit.com/downloads/pspdfkit-android-quickstart-guide.pdf" download="Document.pdf">this QuickStart Guide PDF</a> as an example. | ||
```shell | ||
cp ~/Downloads/Document.pdf platforms/android/app/src/main/assets/Document.pdf | ||
``` | ||
6. Now open your `index.js` file located in `www/js/` and paste the below code into the `onDeviceReady()` function. For this to work you need to create a folder called `documents` in `www` and paste a PDF in this folder. | ||
6. Now open your `index.js` file located in `www/js/` and paste the below code into the `onDeviceReady()` function: | ||
```javascript | ||
PSPDFKit.presentFromAssets("www/documents/A.pdf", { | ||
PSPDFKit.present("file:///android_asset/Document.pdf", { | ||
title: "My PDF Document", | ||
@@ -189,80 +322,208 @@ page: 0, | ||
scrollMode: PSPDFKit.ScrollMode.CONTINUOUS, | ||
useImmersiveMode: true | ||
useImmersiveMode: true, | ||
}); | ||
``` | ||
7. You are now ready to build and test your app! | ||
7. [Start your emulator](https://developer.android.com/studio/run/emulator#runningemulator). | ||
8. The app is now ready to launch: | ||
```shell | ||
cordova build | ||
cordova run | ||
cordova emulate android | ||
``` | ||
### Quickstart Guide Ionic | ||
## Running the PSPDFKit-Demo Cordova Example | ||
For more information regarding the Ionic installation you can check out the [official Ionic installation guide](https://ionicframework.com/docs/v1/guide/installation.html). | ||
1. Open the Terminal app and clone the GitHub repository: | ||
1. Create a new Ionic project from the command line using the [Ionic Command-Line Interface (CLI)](https://ionicframework.com/docs/cli/start/) . | ||
```shell | ||
git clone https://github.com/PSPDFKit/pspdfkit-cordova.git | ||
``` | ||
2. Change the current working directory to the example project’s folder: | ||
```shell | ||
ionic start todo blank --type ionic1 | ||
cd pspdfkit-cordova/examples/cordova/PSPDFKit-Demo | ||
``` | ||
It will then ask you if you want to integrate your new app with Cordova, answer with yes. After the process is finished change to the newly created Ionic project directory. | ||
2. Install the dependencies: | ||
```shell | ||
cd todo | ||
npm install | ||
``` | ||
2. Add Android platform support to your project. This plugin requires the latest `cordova-android` plugin 8+. | ||
3. Add the Android platform: | ||
```shell | ||
ionic cordova platform add android | ||
cordova platform add android | ||
``` | ||
3. Install the PSPDFKit plugin: | ||
4. Add the trial license key to the `platforms/android/local.properties` file: | ||
```shell | ||
echo "pspdfkit.license=LICENSE_KEY_GOES_HERE" >> platforms/android/local.properties | ||
``` | ||
5. Copy the PDF document from the `www` directory into your project’s assets directory: | ||
```shell | ||
cp www/Document.pdf platforms/android/app/src/main/assets/Document.pdf | ||
``` | ||
6. [Start your emulator](https://developer.android.com/studio/run/emulator#runningemulator). | ||
7. The app is now ready to launch: | ||
```shell | ||
cordova emulate android | ||
``` | ||
## New Ionic Project | ||
Let's create a minimal Ionic app that integrates PSPDFKit and uses the `pspdfkit-cordova` plugin. | ||
### Quickstart Guide Ionic | ||
1. Create a new Ionic project from the command line using the [Ionic Command-Line Interface (CLI)](https://ionicframework.com/docs/cli/start/) . | ||
```shell | ||
ionic start PSPDFKit-Demo blank tabs --cordova --type=angular | ||
cd PSPDFKit-Demo | ||
``` | ||
2. Install the PSPDFKit plugin: | ||
```shell | ||
ionic cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git | ||
``` | ||
4. Next you need to set up your PSPDFKit license key. If you don't have a license key yet, you can get one by requesting an evaluation version of PSPDFKit at https://pspdfkit.com/try. Specify the `pspdfkit.license` property inside your Android app's `platforms/android/local.properties` file, create the file if it does not exist: | ||
3. Open `config.xml` in a text editor to enable AndroidX and to change the deployment target to iOS 12 or later: | ||
```properties | ||
# This is the LICENSE_KEY you received when requesting a demo or from the customer portal. | ||
pspdfkit.license=LICENSE_STRING | ||
```bash | ||
open config.xml | ||
``` | ||
> Note: If you're already a customer then please make sure that the package ID matches with your bundle ID that's assigned to your license (e.g. com.ionic.test). You can check this in your `AndroidManifest.xml` by searching for `package`. If you are using a trial license then you don't have to worry about that. | ||
Your `config.xml` file should look like this: | ||
5. Now open your `app.js` file located in `www/js/` and paste the below code into the `$ionicPlatform.ready(function() {}` function. For this to work you need to create a folder called `documents` in `www` and paste a PDF in this folder. | ||
```diff | ||
... | ||
<platform name="android"> | ||
- <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
- <application android:networkSecurityConfig="@xml/network_security_config" /> | ||
- </edit-config> | ||
+ <preference name="AndroidXEnabled" value="true" /> | ||
... | ||
</platform> | ||
<platform name="ios"> | ||
<allow-intent href="itms:*" /> | ||
<allow-intent href="itms-apps:*" /> | ||
+ <allow-navigation href="*" /> | ||
+ <preference name="deployment-target" value="12.0" /> | ||
... | ||
</platform> | ||
... | ||
``` | ||
```javascript | ||
PSPDFKit.showDocumentFromAssets("www/documents/Document.pdf", { | ||
title: "My PDF Document", | ||
page: 0, | ||
scrollDirection: PSPDFKit.PageScrollDirection.VERTICAL, | ||
scrollMode: PSPDFKit.ScrollMode.CONTINUOUS, | ||
useImmersiveMode: true | ||
}); | ||
4. Declare PSPDFKit in the src/declarations.d.ts file: | ||
```shell | ||
echo "declare var PSPDFKit: any;" >> src/declarations.d.ts | ||
``` | ||
6. Now you need to build the app to see if everything works correctly: | ||
5. Open the `src/app/app.component.ts` file: | ||
```shell | ||
ionic cordova build | ||
open src/app/app.component.ts | ||
``` | ||
7. And finally to run the app on a real device simply enter: | ||
6. Replace the entire contents of the `app.component.ts` file with the following code snippet: | ||
```typescript | ||
import { Component } from "@angular/core"; | ||
import { Platform } from "@ionic/angular"; | ||
@Component({ | ||
selector: "app-root", | ||
templateUrl: "app.component.html", | ||
styleUrls: ["app.component.scss"], | ||
}) | ||
export class AppComponent { | ||
constructor(private platform: Platform) { | ||
this.platform.ready().then(() => { | ||
PSPDFKit.setLicenseKey("LICENSE_KEY_GOES_HERE"); | ||
const DOCUMENT = this.platform.is("ios") | ||
? "Document.pdf" | ||
: "file:///android_asset/Document.pdf"; | ||
PSPDFKit.present(DOCUMENT); | ||
}); | ||
} | ||
} | ||
``` | ||
7. Run `ionic cordova platform add android` to add the Android platform. | ||
8. Next, you need to set up your PSPDFKit license key. If you don't have a license key yet, you can get one by requesting an evaluation version of PSPDFKit at https://pspdfkit.com/try. Specify the `pspdfkit.license` property inside your Android app's `platforms/android/local.properties` file, create the file if it does not exist: | ||
```shell | ||
ionic cordova run android | ||
echo "pspdfkit.license=LICENSE_KEY_GOES_HERE" >> platforms/android/local.properties | ||
``` | ||
Or if you want to run the app on a simulator you can use: | ||
> Note: If you're already a customer then please make sure that the package ID matches with your bundle ID that's assigned to your license (e.g. io.ionic.starter). You can check this in your `AndroidManifest.xml` by searching for `package`. If you are using a trial license then you don't have to worry about that. | ||
9. Add the PDF document you want to display in your project’s `assets` directory. You can use <a href="https://pspdfkit.com/downloads/pspdfkit-android-quickstart-guide.pdf" download="Document.pdf">this QuickStart Guide PDF</a> as an example. | ||
```shell | ||
cp ~/Downloads/Document.pdf platforms/android/app/src/main/assets/Document.pdf | ||
``` | ||
7. [Start your emulator](https://developer.android.com/studio/run/emulator#runningemulator). | ||
8. The app is now ready to launch: | ||
```shell | ||
ionic cordova emulate android | ||
``` | ||
## Running the PSPDFKit-Demo Ionic Example | ||
1. Open the Terminal app and clone the GitHub repository: | ||
```shell | ||
git clone https://github.com/PSPDFKit/pspdfkit-cordova.git | ||
``` | ||
2. Change the current working directory to the example project’s folder: | ||
```shell | ||
cd pspdfkit-cordova/examples/ionic/PSPDFKit-Demo | ||
``` | ||
2. Install the dependencies: | ||
```shell | ||
npm install | ||
``` | ||
3. Add the Android platform: | ||
```shell | ||
ionic cordova platform add android | ||
``` | ||
4. Add the trial license key to the `platforms/android/local.properties` file: | ||
```shell | ||
echo "pspdfkit.license=LICENSE_KEY_GOES_HERE" >> platforms/android/local.properties | ||
``` | ||
5. Copy the PDF document from the `resources` directory into your project’s `assets` directory: | ||
```shell | ||
cp resources/Document.pdf platforms/android/app/src/main/assets/Document.pdf | ||
``` | ||
6. [Start your emulator](https://developer.android.com/studio/run/emulator#runningemulator). | ||
7. The app is now ready to launch: | ||
```shell | ||
ionic cordova emulate android | ||
``` | ||
## What your project structure should look like | ||
@@ -306,11 +567,13 @@ | ||
```javascript | ||
window.onerror = function(msg, url, line, col, error) { | ||
var extra = !col ? '' : '\ncolumn: ' + col; | ||
extra += !error ? '' : '\nerror: ' + error; | ||
console.log("ErrorReport: " + msg + "\nurl: " + url + "\nline: " + line + extra); | ||
return true; | ||
window.onerror = function (msg, url, line, col, error) { | ||
var extra = !col ? "" : "\ncolumn: " + col; | ||
extra += !error ? "" : "\nerror: " + error; | ||
console.log( | ||
"ErrorReport: " + msg + "\nurl: " + url + "\nline: " + line + extra | ||
); | ||
return true; | ||
}; | ||
``` | ||
### Conflicts with Android Support Library/AndroidX | ||
### Conflicts with Android Support Library/AndroidX | ||
@@ -329,11 +592,11 @@ When running `cordova build` for a project with multiple plugins installed, it can happen that you see a build error like this: | ||
``` | ||
cordova plugin add cordova-plugin-androidx | ||
``` | ||
``` | ||
cordova plugin add cordova-plugin-androidx | ||
``` | ||
2. Install the [`cordova-plugin-androidx-adapter`](https://github.com/dpa99c/cordova-plugin-androidx-adapter) plugin, which will enable auto-migration of all outdated Cordova plugins, so that they also use AndroidX instead of the Support Library. | ||
``` | ||
cordova plugin add cordova-plugin-androidx-adapter | ||
``` | ||
``` | ||
cordova plugin add cordova-plugin-androidx-adapter | ||
``` | ||
@@ -458,2 +721,3 @@ 3. Run `cordova build`. This will process and update all third-party plugins to use AndroidX, and will then build your project. | ||
Example: | ||
``` | ||
@@ -467,3 +731,3 @@ * What went wrong: | ||
Simply open your `platforms/android/pspdfkit-cordova/YOURAPP-pspdfkit.gradle` file and change the version. In this case changing `26.0.2` to `26.0.1` can already fix such issues because sometimes specific support library versions are not available anymore. | ||
Open your `platforms/android/pspdfkit-cordova/YOURAPP-pspdfkit.gradle` file and change the version. In this case changing `26.0.2` to `26.0.1` can already fix such issues because sometimes specific support library versions are not available anymore. | ||
@@ -470,0 +734,0 @@ ### PSPDFKit name not found in TypeScript app |
@@ -7,34 +7,135 @@ # Cordova Plugin for PSPDFKit 10 for iOS | ||
## Requirements | ||
### Cordova Requirements | ||
- The latest [Xcode](https://developer.apple.com/xcode/) | ||
- PSPDFKit 10.2.0 for iOS or later | ||
- Cordova Lib >= 10.0.0 | ||
- Cordova iOS >= 5.1.1 | ||
- CocoaPods >= 1.10.1 | ||
- A [development environment setup](https://cordova.apache.org/#getstarted) for running Cordova projects. | ||
- The [latest stable version of cordova-lib](https://github.com/apache/cordova-lib/releases). | ||
- The [latest stable version of cordova-ios](https://github.com/apache/cordova-ios/releases). | ||
- The [latest stable version of Xcode](https://developer.apple.com/xcode/). | ||
- The [latest stable version of CocoaPods](https://guides.cocoapods.org/using/getting-started.html#installation). | ||
## Installation | ||
### Ionic Requirements | ||
- A [development environment setup](https://ionicframework.com/getting-started/) for running Ionic projects. | ||
- The [latest stable version of Node.js](https://nodejs.org/en/). | ||
- The [latest stable version of Ionic CLI](https://ionicframework.com/docs/cli). | ||
- The [latest stable version of `cordova-res`](https://www.npmjs.com/package/cordova-res). | ||
- The [latest stable version of Xcode](https://developer.apple.com/xcode/). | ||
- The [latest stable version of CocoaPods](https://guides.cocoapods.org/using/getting-started.html#installation). | ||
## Cordova Installation | ||
We assume that you have [an existing Cordova project](https://cordova.apache.org/#getstarted). | ||
1. Run `cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git` to install the `pspdfkit-cordova` plugin. | ||
2. Update your `Podfile`: `cd platforms/ios` and open your `Podfile` in a text editor. Make sure the platform is set to iOS 12 or later. Your `Podfile` should look like this: | ||
1. Open the Terminal app and change the location of the current working directory inside the newly created project: | ||
```bash | ||
cd path/to/YourProject | ||
``` | ||
2. Remove all the platforms from your project to properly propagate the changes in the `config.xml` file below throughout the project: | ||
```bash | ||
cordova platform remove android | ||
cordova platform remove ios | ||
``` | ||
3. Open `config.xml` in a text editor to enable AndroidX and to change the deployment target to iOS 12 or later: | ||
```bash | ||
open config.xml | ||
``` | ||
Your `config.xml` file should look like this: | ||
```diff | ||
source 'https://github.com/CocoaPods/Specs.git' | ||
- platform :ios, '10.0' | ||
+ platform :ios, '12.0' | ||
use_frameworks! | ||
target 'CordovaDemo' do | ||
project 'CordovaDemo.xcodeproj' | ||
pod 'PSPDFKit', podspec: 'https://customers.pspdfkit.com/pspdfkit-ios/latest.podspec' | ||
end | ||
... | ||
<platform name="android"> | ||
+ <preference name="AndroidXEnabled" value="true" /> | ||
<allow-intent href="market:*" /> | ||
</platform> | ||
<platform name="ios"> | ||
<allow-intent href="itms:*" /> | ||
<allow-intent href="itms-apps:*" /> | ||
+ <preference name="deployment-target" value="12.0" /> | ||
... | ||
</platform> | ||
... | ||
``` | ||
3. If your application is targeting iOS versions **prior to iOS 12.2** and your application **does not already contain any Swift code**, then you need to make sure Xcode bundles Swift standard libraries with your application distribution. To to so, open your target Build Settings and enable `Always Embed Swift Standard Libraries`: | ||
4. Add the PSPDFKit plugin: | ||
![always-embed-swift-standard-libraries.png](screenshots/always-embed-swift-standard-libraries.png) | ||
```bash | ||
cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git | ||
``` | ||
4. Install the Pods: run `pod install`. | ||
5. Add back all the platforms: | ||
```bash | ||
cordova platform add android | ||
cordova platform add ios | ||
``` | ||
## Ionic Installation | ||
We assume that you have [an existing Ionic project](https://ionicframework.com/docs/cli/start/). | ||
1. Open the Terminal app and change the location of the current working directory inside the newly created project: | ||
```bash | ||
cd path/to/YourProject | ||
``` | ||
2. Remove all the platforms from your project to properly propagate the changes in the `config.xml` file below throughout the project: | ||
```bash | ||
ionic cordova platform remove android | ||
ionic cordova platform remove ios | ||
``` | ||
3. Open `config.xml` in a text editor to enable AndroidX and to change the deployment target to iOS 12 or later: | ||
```bash | ||
open config.xml | ||
``` | ||
Your `config.xml` file should look like this: | ||
```diff | ||
... | ||
<platform name="android"> | ||
- <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
- <application android:networkSecurityConfig="@xml/network_security_config" /> | ||
- </edit-config> | ||
+ <preference name="AndroidXEnabled" value="true" /> | ||
... | ||
</platform> | ||
<platform name="ios"> | ||
<allow-intent href="itms:*" /> | ||
<allow-intent href="itms-apps:*" /> | ||
+ <allow-navigation href="*" /> | ||
+ <preference name="deployment-target" value="12.0" /> | ||
... | ||
</platform> | ||
... | ||
``` | ||
4. Add back all the platforms: | ||
```bash | ||
ionic cordova platform add android | ||
ionic cordova platform add ios | ||
``` | ||
5. Add the PSPDFKit plugin: | ||
```bash | ||
ionic cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git | ||
``` | ||
6. Declare PSPDFKit in the src/declarations.d.ts file: | ||
```shell | ||
echo "declare var PSPDFKit: any;" >> src/declarations.d.ts | ||
``` | ||
## Usage | ||
@@ -51,7 +152,7 @@ | ||
pageMode: "single", | ||
backgroundColor: "black" | ||
backgroundColor: "black", | ||
}); | ||
// Show a PDF document with a callback. | ||
PSPDFKit.present("pdf/document.pdf", function() { | ||
PSPDFKit.present("pdf/document.pdf", function () { | ||
alert("pdf has appeared"); | ||
@@ -64,3 +165,3 @@ }); | ||
// Get the page number. | ||
PSPDFKit.getPage(function(page) { | ||
PSPDFKit.getPage(function (page) { | ||
alert("Current page: " + page); | ||
@@ -70,12 +171,64 @@ }); | ||
5. Add the PSPDFKit plugin: | ||
```bash | ||
cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git | ||
``` | ||
## Getting Started | ||
#### New Cordova Project | ||
### New Cordova Project | ||
Let's create a simple Corodva app that integrates PSPDFKit and uses the `pspdfkit-cordova` plugin. | ||
Let's create a minimal Corodva app that integrates PSPDFKit and uses the `pspdfkit-cordova` plugin. | ||
1. Run `cordova create Cordova-Demo com.pspdfkit.demo CordovaDemo` to create a new Cordova project. | ||
2. Add a sample PDF into your `www` directory: `www/pdf/document.pdf`. | ||
3. Modify the `onDeviceReady` function in `www/js/index.js` like so: | ||
1. Create the new Cordova project by running app by running the following command: | ||
```bash | ||
cordova create PSPDFKit-Demo com.pspdfkit.demo PSPDFKit-Demo | ||
cd PSPDFKit-Demo | ||
``` | ||
2. Open `config.xml` and change the deployment target to iOS 12 or later: | ||
```diff | ||
... | ||
<platform name="android"> | ||
+ <preference name="AndroidXEnabled" value="true" /> | ||
<allow-intent href="market:*" /> | ||
</platform> | ||
<platform name="ios"> | ||
<allow-intent href="itms:*" /> | ||
<allow-intent href="itms-apps:*" /> | ||
+ <preference name="deployment-target" value="12.0" /> | ||
... | ||
</platform> | ||
... | ||
``` | ||
3. Add the PSPDFKit plugin: | ||
```bash | ||
cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git | ||
``` | ||
4. Add the iOS platform | ||
```bash | ||
cordova platform add ios | ||
``` | ||
5. Add the PDF document you want to display in your project’s `www` directory. You can use <a href="https://pspdfkit.com/downloads/pspdfkit-ios-quickstart-guide.pdf" download="Document.pdf">this QuickStart Guide PDF</a> as an example. | ||
```bash | ||
cp ~/Downloads/Document.pdf www/Document.pdf | ||
``` | ||
6. Open the www/js/index.js file: | ||
```bash | ||
open www/js/index.js | ||
``` | ||
7. Modify the onDeviceReady function like so: | ||
```javascript | ||
@@ -85,70 +238,177 @@ onDeviceReady: function() { | ||
// Set your license key here. | ||
PSPDFKit.setLicenseKey("YOUR KEY"); | ||
// Show pdf with in single page mode. | ||
PSPDFKit.present('pdf/document.pdf', { | ||
pageMode: 'single', | ||
}); | ||
PSPDFKit.setLicenseKey("LICENSE_KEY_GOES_HERE"); | ||
const DOCUMENT = (window.cordova.platformId === "ios") ? "Document.pdf" : "file:///android_asset/Document.pdf"; | ||
PSPDFKit.present(DOCUMENT); | ||
}, | ||
``` | ||
4. `cd` into `Cordova-Demo` and run `cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git` to install the `pspdfkit-cordova` plugin. | ||
5. Open `config.xml` and change the deployment target to iOS 12 or later: | ||
8. The app is now ready to launch: | ||
```diff | ||
<platform name="ios"> | ||
<allow-intent href="itms:*" /> | ||
<allow-intent href="itms-apps:*" /> | ||
+ <preference name="deployment-target" value="12.0" /> | ||
</platform> | ||
```bash | ||
cordova emulate ios | ||
``` | ||
6. Run `cordova platform add ios` to add the iOS platform. | ||
7. If your application is targeting iOS versions **prior to iOS 12.2** and your application **does not already contain any Swift code**, then you need to make sure Xcode bundles Swift standard libraries with your application distribution. To to so, open your target Build Settings and enable `Always Embed Swift Standard Libraries`: | ||
### Running the PSPDFKit-Demo Cordova Example | ||
![always-embed-swift-standard-libraries.png](screenshots/always-embed-swift-standard-libraries.png) | ||
1. Open the Terminal app and clone the GitHub repository: | ||
8. Run the app: Open `platforms/ios/CordovaDemo.xcworkspace` in Xcode, then build and run, or run `cordova emulate ios` in the Terminal. | ||
```bash | ||
git clone https://github.com/PSPDFKit/pspdfkit-cordova.git | ||
``` | ||
#### New Ionic Project | ||
2. Change the current working directory to the example project’s folder: | ||
Let's create a simple Ionic app that integrates PSPDFKit and uses the `pspdfkit-cordova` plugin. | ||
```bash | ||
cd pspdfkit-cordova/examples/cordova/PSPDFKit-Demo | ||
``` | ||
1. Run `ionic start IonicDemo blank --type=angular` to create a new Ionic project. | ||
2. `cd` into `IonicDemo` and run `ionic cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git` to install the `pspdfkit-cordova` plugin. | ||
3. Open `config.xml` and change the deployment target to iOS 12 or later: | ||
2. Install the dependencies: | ||
```bash | ||
npm install | ||
``` | ||
3. Add the iOS platform: | ||
```bash | ||
cordova platform add ios | ||
``` | ||
4. The app is now ready to launch: | ||
```bash | ||
cordova emulate ios | ||
``` | ||
### New Ionic Project | ||
Let's create a minimal Ionic app that integrates PSPDFKit and uses the `pspdfkit-cordova` plugin. | ||
1. Create a new Ionic project from the command line using the [Ionic Command-Line Interface (CLI)](https://ionicframework.com/docs/cli/start/): | ||
```shell | ||
ionic start PSPDFKit-Demo blank tabs --cordova --type=angular | ||
cd PSPDFKit-Demo | ||
``` | ||
2. Install the PSPDFKit plugin: | ||
```shell | ||
ionic cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git | ||
``` | ||
3. Open `config.xml` in a text editor to enable AndroidX and to change the deployment target to iOS 12 or later: | ||
```bash | ||
open config.xml | ||
``` | ||
Your `config.xml` file should look like this: | ||
```diff | ||
<platform name="ios"> | ||
<allow-intent href="itms:*" /> | ||
<allow-intent href="itms-apps:*" /> | ||
+ <allow-navigation href="*" /> | ||
+ <preference name="deployment-target" value="12.0" /> | ||
</platform> | ||
... | ||
<platform name="android"> | ||
- <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
- <application android:networkSecurityConfig="@xml/network_security_config" /> | ||
- </edit-config> | ||
+ <preference name="AndroidXEnabled" value="true" /> | ||
... | ||
</platform> | ||
<platform name="ios"> | ||
<allow-intent href="itms:*" /> | ||
<allow-intent href="itms-apps:*" /> | ||
+ <allow-navigation href="*" /> | ||
+ <preference name="deployment-target" value="12.0" /> | ||
... | ||
</platform> | ||
... | ||
``` | ||
4. Declare `PSPDFKit` in `src/declarations.d.ts` (create this file first): `declare var PSPDFKit: any;` | ||
5. Modifying `src/app/app.component.ts` to use the PSPDFKit plugin to Present a PDF: | ||
4. Declare PSPDFKit in the src/declarations.d.ts file: | ||
```javascript | ||
initializeApp() { | ||
this.platform.ready().then(() => { | ||
this.statusBar.styleDefault(); | ||
this.splashScreen.hide(); | ||
PSPDFKit.setLicenseKey('YOUR KEY'); | ||
PSPDFKit.present('pdf/document.pdf', {}); | ||
}); | ||
```bash | ||
echo "declare var PSPDFKit: any;" >> src/declarations.d.ts | ||
``` | ||
5. Open the `src/app/app.component.ts` file: | ||
```bash | ||
open src/app/app.component.ts | ||
``` | ||
6. Replace the entire contents of the `app.component.ts` file with the following code snippet: | ||
```typescript | ||
import { Component } from "@angular/core"; | ||
import { Platform } from "@ionic/angular"; | ||
@Component({ | ||
selector: "app-root", | ||
templateUrl: "app.component.html", | ||
styleUrls: ["app.component.scss"], | ||
}) | ||
export class AppComponent { | ||
constructor(private platform: Platform) { | ||
this.platform.ready().then(() => { | ||
PSPDFKit.setLicenseKey("LICENSE_KEY_GOES_HERE"); | ||
const DOCUMENT = this.platform.is("ios") | ||
? "Document.pdf" | ||
: "file:///android_asset/Document.pdf"; | ||
PSPDFKit.present(DOCUMENT); | ||
}); | ||
} | ||
} | ||
``` | ||
6. Run `ionic cordova platform add ios` to add the iOS platform. | ||
7. Run `ionic cordova prepare ios` to prepare iOS platform. | ||
8. If your application is targeting iOS versions **prior to iOS 12.2** and your application **does not already contain any Swift code**, then you need to make sure Xcode bundles Swift standard libraries with your application distribution. To to so, open your target Build Settings and enable `Always Embed Swift Standard Libraries`: | ||
7. Run `ionic cordova platform add ios` to add the iOS platform. | ||
8. Add the PDF document you want to display in your project’s `platforms/ios/www directory`. You can use <a href="https://pspdfkit.com/downloads/pspdfkit-ios-quickstart-guide.pdf" download="Document.pdf">this QuickStart Guide PDF</a> as an example. | ||
![always-embed-swift-standard-libraries.png](screenshots/always-embed-swift-standard-libraries.png) | ||
```bash | ||
cp ~/Downloads/Document.pdf platforms/ios/platform_www/Document.pdf | ||
``` | ||
9. Add a sample PDF into your `platforms/ios/www` directory: `platforms/ios/www/pdf/document.pdf`. | ||
10. Run the app: Open `platforms/ios/MyApp.xcworkspace` in Xcode, then build and run, or run `ionic cordova emulate ios` in the Terminal. | ||
9. The app is now ready to launch: | ||
```bash | ||
ionic cordova emulate ios | ||
``` | ||
### Running the PSPDFKit-Demo Ionic Example | ||
1. Open the Terminal app and clone the GitHub repository: | ||
```bash | ||
git clone https://github.com/PSPDFKit/pspdfkit-cordova.git | ||
``` | ||
2. Change the current working directory to the example project’s folder: | ||
```bash | ||
cd pspdfkit-cordova/examples/ionic/PSPDFKit-Demo | ||
``` | ||
2. Install the dependencies: | ||
```bash | ||
npm install | ||
``` | ||
3. Add the iOS platform: | ||
```bash | ||
ionic cordova platform add ios | ||
``` | ||
4. Copy the PDF document from the `resources` directory into your project’s `platform_www` directory: | ||
```bash | ||
cp resources/Document.pdf platforms/ios/platform_www/Document.pdf | ||
``` | ||
5. The app is now ready to launch: | ||
```bash | ||
ionic cordova emulate ios | ||
``` | ||
## API | ||
@@ -162,3 +422,3 @@ | ||
```sh | ||
```bash | ||
Error: Cannot find plugin.xml for plugin "PSPDFKit-Cordova". Please try adding it again. | ||
@@ -171,2 +431,75 @@ ``` | ||
### Problem: | ||
```bash | ||
Installing "pspdfkit-cordova" for ios | ||
Running command: pod install --verbose | ||
/Users/yourUsername/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.10.1/lib/cocoapods/external_sources/podspec_source.rb:19: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open | ||
Failed to install 'pspdfkit-cordova': Error: pod: Command failed with exit code 1 Error output: | ||
/Users/yourUsername/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.10.1/lib/cocoapods/external_sources/podspec_source.rb:19: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open | ||
at ChildProcess.whenDone (/Users/yourUsername/Downloads/pspdfkit-cordova/examples/ionic/PSPDFKit-Demo/node_modules/cordova-common/src/superspawn.js:136:25) | ||
at ChildProcess.emit (events.js:315:20) | ||
at maybeClose (internal/child_process.js:1048:16) | ||
at Socket.<anonymous> (internal/child_process.js:439:11) | ||
at Socket.emit (events.js:315:20) | ||
at Pipe.<anonymous> (net.js:673:12) | ||
pod: Command failed with exit code 1 Error output: | ||
/Users/yourUsername/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/cocoapods-1.10.1/lib/cocoapods/external_sources/podspec_source.rb:19: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open | ||
[ERROR] An error occurred while running subprocess cordova. | ||
cordova platform add ios exited with exit code 1. | ||
Re-running this command with the --verbose flag may provide more | ||
information. | ||
``` | ||
### Solution: | ||
1. Open your project's Podfile: | ||
```bash | ||
open platforms/ios/Podifile | ||
``` | ||
2. Modify your Podfile like so: | ||
```diff | ||
source 'https://github.com/CocoaPods/Specs.git' | ||
- platform :ios, '11.0' | ||
+ platform :ios, '12.0' | ||
use_frameworks! | ||
target 'MyApp' do | ||
project 'MyApp.xcodeproj' | ||
pod 'PSPDFKit', podspec: 'https://customers.pspdfkit.com/pspdfkit-ios/latest.podspec' | ||
end | ||
``` | ||
3. Change your local working directory to `platforms/ios`: | ||
```bash | ||
cd platforms/ios/ | ||
``` | ||
4. Run `pod install` | ||
5. Change your local working directory back to the root of your project: | ||
```bash | ||
cd ../../ | ||
``` | ||
6. Launch your app: | ||
**Cordova:** | ||
```bash | ||
cordova emulate ios | ||
``` | ||
**Ionic:** | ||
```bash | ||
ionic cordova emulate ios | ||
``` | ||
## Migration Guide from `Cordova-iOS` | ||
@@ -173,0 +506,0 @@ |
{ | ||
"name": "pspdfkit-cordova", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "PSPDFKit Cordova Plugin for Android and iOS", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -13,3 +13,3 @@ # PSPDFKit-Cordova | ||
#### Cordova | ||
### Cordova | ||
@@ -20,3 +20,3 @@ ```sh | ||
#### Ionic | ||
### Ionic | ||
@@ -29,6 +29,14 @@ ```sh | ||
- [Android](/docs/android#installation) | ||
- [iOS](/docs/ios#installation) | ||
- [Cordova Installation Android](/docs/android#cordova-installation). | ||
- [Cordova Installation iOS](/docs/ios#cordova-installation). | ||
- [Ionic Installation Android](/docs/android#ionic-installation). | ||
- [Ionic Installation iOS](/docs/ios#ionic-installation). | ||
## Requirements | ||
- [Android Cordova Requirements](docs/android#cordova-requirements). | ||
- [Android Ionic Requirements](docs/android#ionic-requirements). | ||
- [iOS Cordova Requirements](docs/ios#cordova-requirements). | ||
- [iOS Ionic Requirements](docs/ios#ionic-requirements). | ||
## Getting Started | ||
@@ -39,6 +47,13 @@ | ||
- [New Cordova Project on Android](/docs/android#new-cordova-project) | ||
- [New Ionic Project on Android](/docs/android#quickstart-guide-ionic) | ||
- [New Ionic Project on Android](/docs/android#new-ionic-project) | ||
- [New Cordova Project on iOS](/docs/ios#new-cordova-project) | ||
- [New Ionic Project on iOS](/docs/ios#new-ionic-project) | ||
## Example Projects | ||
- [Running the PSPDFKit-Demo Cordova Example on Android](/docs/android#running-the-pspdfkit-demo-cordova-example) | ||
- [Running the PSPDFKit-Demo Cordova Example on iOS](/docs/ios#running-the-pspdfkit-demo-cordova-example) | ||
- [Running the PSPDFKit-Demo Ionic Example on Android](/docs/android#running-the-pspdfkit-demo-ionic-example) | ||
- [Running the PSPDFKit-Demo Ionic Example on iOS](/docs/ios#running-the-pspdfkit-demo-ionic-example) | ||
## Documentation | ||
@@ -45,0 +60,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13866121
168
39086
93
1
1