Skip to content

Latest commit

 

History

History
 
 

ios

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Cordova Plugin for PSPDFKit for iOS

The PSPDFKit SDK is a framework that allows you to view, annotate, sign, and fill PDF forms on iOS, Android, Windows, macOS, and Web.

PSPDFKit comes with open source plugins for Cordova on both iOS and Android.

Cordova Requirements

Ionic Requirements

Cordova Installation

Follow these steps to install PSPDFKit-Cordova in your Cordova project.

Ionic Installation

Follow these steps to install PSPDFKit-Cordova in your Ionic project.

Usage

The plugin is accessed via the PSPDFKit singleton. Here are some example calls:

// Set your license key here.
PSPDFKit.setLicenseKey("YOUR KEY");

// Show pdf with in single page mode, with a black background.
PSPDFKit.present("pdf/document.pdf", {
  pageMode: "single",
  backgroundColor: "black",
});

// Show a PDF document with a callback.
PSPDFKit.present("pdf/document.pdf", function () {
  alert("pdf has appeared");
});

// Scroll to page 1.
PSPDFKit.setPage(1, true);

// Get the page number.
PSPDFKit.getPage(function (page) {
  alert("Current page: " + page);
});

Getting Started

New Cordova Project

Follow these steps to install PSPDFKit-Cordova in a newly created Cordova project.

Running the PSPDFKit-Demo Cordova Example

Follow these steps to run the PSPDFKit-Demo Cordova example project.

New Ionic Project

Follow these steps to install PSPDFKit-Cordova in a newly created Ionic project.

Running the PSPDFKit-Demo Ionic Example

Follow these steps to run the PSPDFKit-Demo Ionic example project.

API

You can find the API documentation in PSPDFKit.js.

Troubleshooting

Problem:

Error: Cannot find plugin.xml for plugin "PSPDFKit-Cordova". Please try adding it again.

Solution:

Run cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git instead of ionic cordova plugin add https://github.com/PSPDFKit/PSPDFKit-Cordova.git.

Problem:

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:
open platforms/ios/Podifile
  1. Modify your Podfile like so:
source 'https://github.com/CocoaPods/Specs.git'
- platform :ios, '11.0'
+ platform :ios, '15.0'
use_frameworks!
target 'MyApp' do
	project 'MyApp.xcodeproj'
	pod 'PSPDFKit', podspec: 'https://customers.pspdfkit.com/pspdfkit-ios/latest.podspec'
end
  1. Change your local working directory to platforms/ios:
cd platforms/ios/
  1. Run pod install
  2. Change your local working directory back to the root of your project:
cd ../../
  1. Launch your app:

Cordova:

cordova emulate ios

Ionic:

ionic cordova emulate ios

Migration Guide from Cordova-iOS

If you were using the old Cordova-iOS Plugin, please follow the steps below to migrate to this plugin:

  1. Remove the old plugin: cordova plugin remove pspdfkit-cordova-ios
  2. Open your Xcode project or workspace and remove PSPDFKit.framework and PSPDFKitUI.framework from your Target:

remove-frameworks

  1. Close your Xcode project or workspace.
  2. Integrate the new pspdfkit-cordova Plugin. See the Install instructions above.
  3. Rename all PSPDFKitPlugin calls to PSPDFKit in your app's JavaScript code:
- PSPDFKitPlugin.setLicenseKey("YOUR KEY");
+ PSPDFKit.setLicenseKey("YOUR KEY");

- PSPDFKitPlugin.present('pdf/document.pdf', {
+ PSPDFKit.present('pdf/document.pdf', {
  pageMode: 'single',
});