Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pspdfkit-cordova): add PSPDFKit-Cordova plugin #3210

Merged
merged 2 commits into from
Oct 30, 2019

Conversation

radazzouz
Copy link
Contributor

@radazzouz radazzouz commented Oct 23, 2019

How to Test in a Newly Created Ionic Project

1. Build the PSPDFKit Ionic Native Plugin From This Branch:

  1. clone this repo and checkout this branch.
  2. cd into Ionic-Native and run npm run build.
  3. The newly built plugin can be found in dist/@ionic-native/pspdfkit-cordova.

2. Integrate Into a Newly Created Ionic Project:

  1. Run ionic start IonicDemo blank --type=angular --id=com.pspdfkit.ionic.example to create a new Ionic project.
  2. cd into IonicDemo and run ionic cordova plugin add pspdfkit-cordova to install the pspdfkit-cordova plugin.
  3. Add a sample PDF into your www directory: www/pdf/document.pdf.
  4. Open config.xml and change the deployment target to iOS 11 or later:
<platform name="ios">
	<allow-intent href="itms:*" />
	<allow-intent href="itms-apps:*" />
+ 	<allow-navigation href="*" />
+	<preference name="deployment-target" value="11.0" />
</platform>
  1. Use your CocoaPods Key: open plugins/pspdfkit-cordova/plugin.xml and replace YOUR_COCOAPODS_KEY_GOES_HERE with your own key. If you’re an existing customer, you can find the CocoaPods and license keys in your customer portal. Otherwise, if you don’t already have PSPDFKit, sign up for our 60-day trial and you will receive an email with the instructions to get started.

  2. Modify src/app/app.module.ts to use PSPDFKit as follows:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
+import { PSPDFKit } from '@ionic-native/PSPDFKit-cordova/ngx';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
  providers: [
    StatusBar,
-   SplashScreen	
+   SplashScreen,
+   PSPDFKit,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}
  1. Modify src/app/app.component.ts to use the PSPDFKit plugin to Present a PDF:
import { Component } from '@angular/core';

import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
+import { PSPDFKit } from '@ionic-native/PSPDFKit-cordova/ngx';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.scss']
})
export class AppComponent {
  constructor(
    private platform: Platform,
    private splashScreen: SplashScreen,
-   private statusBar: StatusBar
+   private statusBar: StatusBar,
+   private pspdfkit: PSPDFKit
  ) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
+     this.pspdfkit.setLicenseKey("YOUR LICENSE KEY GOES HERE");
+     this.pspdfkit.present('pdf/document.pdf')
    });
  }
}
  1. Run ionic cordova platform add ios to add the iOS platform.
  2. Copy the Ionic Native plugin that you built from the step above into your projects node_modules/@ionic-native/. Assuming both repos are forked next to each other, you should run the this command cp -r ../Ionic-Native/dist/@ionic-native/pspdfkit-cordova /node_modules/@ionic-native/.
  3. Run ionic cordova prepare ios to prepare iOS platform.
  4. 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:

always-embed-swift-standard-libraries

  1. Run the app: Open platforms/ios/MyApp.xcworkspace in Xcode, then build and run, or run ionic cordova emulate ios in the Terminal.

@danielsogl danielsogl self-assigned this Oct 30, 2019
@danielsogl danielsogl added the target: minor This PR is targeted for the next minor release label Oct 30, 2019
@danielsogl danielsogl merged commit 86cca49 into danielsogl:master Oct 30, 2019
@radazzouz radazzouz deleted the rad/pspdfkit-cordova branch October 30, 2019 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants