Skip to content

Commit

Permalink
Merge pull request #29 from PSPDFKit/rad/update-to-pspdfkit7
Browse files Browse the repository at this point in the history
Update to PSPDFKit 7
  • Loading branch information
radazzouz authored Oct 4, 2017
2 parents 7c79767 + 8834c5f commit fddc242
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ android/app/libs
*.keystore

PSPDFKit/PSPDFKit.framework
PSPDFKit/PSPDFKitUI.framework
samples/Catalog/android/pspdfkit-lib/*.aar

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ See our [announcement blog post](https://pspdfkit.com/blog/2016/react-native-mod
### iOS

#### Requirements
- Xcode 8.3.3
- PSPDFKit >= 6.9.3
- react-native >= 0.48.1
- Xcode 9
- PSPDFKit >= 7.0.0
- react-native >= 0.48.4

#### Getting Started

**Note:** If you want to integrate PSPDFKit using CocoaPods, use [these instructions](ios/cocoapods.md) instead.

Let's create a simple app that integrates `PSPDFKit.framework` and uses the `react-native-pspdfkit` module.
Let's create a simple app that integrates PSPDFKit and uses the `react-native-pspdfkit` module.

1. Make sure `react-native-cli` is installed: `yarn global add react-native-cli`
2. Create the app with `react-native init YourApp`.
3. Step into your newly created app folder: `cd YourApp`
4. Install `react-native-pspdfkit` from GitHub: `yarn add github:PSPDFKit/react-native`
5. Link module `react-native-pspdfkit`: `react-native link react-native-pspdfkit`
6. Create the folder `ios/PSPDFKit` and copy `PSPDFKit.framework` into it.
6. Create the folder `ios/PSPDFKit` and copy `PSPDFKit.framework` and `PSPDFKitUI.framework` into it.
7. Open `ios/YourApp.xcodeproj` in Xcode: `open ios/YourApp.xcodeproj`
8. Make sure the deployment target is set to 9.0 or higher:
![Deployment Target](screenshots/deployment-target.png)
9. Change "View controller-based status bar appearance" to `YES` in `Info.plist`:
![View Controller-Based Status Bar Appearance](screenshots/view-controller-based-status-bar-appearance.png)
10. Link with the `libRCTPSPDFKit.a` static library (if `libRCTPSPDFKit.a` is already there but greyed out, delete it and link it again):
![Linking Static Library](screenshots/linking-static-library.png)
11. Embed `PSPDFKit.framework` by drag and dropping it into the "Embedded Binaries" section of the "YourApp" target (Select "Create groups"). This will also add it to the "Linked Framworks and Libraries" section:
11. Embed `PSPDFKit.framework` and `PSPDFKitUI.framework` by drag and dropping it into the "Embedded Binaries" section of the "YourApp" target (Select "Create groups"). This will also add it to the "Linked Framworks and Libraries" section:
![Embedding PSPDFKit](screenshots/embedding-pspdfkit.png)
12. Add a PDF by drag and dropping it into your Xcode project (Select "Create groups" and add to target "YourApp"). This will add the document to the "Copy Bundle Resources" build phase:
![Adding PDF](screenshots/adding-pdf.png)
Expand Down Expand Up @@ -102,7 +102,7 @@ PSPDFKit.present('document.pdf', {

#### Running Catalog Project

- Copy `PSPDFKit.framework` into the `PSPDFKit` directory.
- Copy `PSPDFKit.framework` and `PSPDFKitUI.framework` into the `PSPDFKit` directory.
- Install dependencies: `yarn install` in `samples/Catalog` directory. (Because of a [bug](https://github.com/yarnpkg/yarn/issues/2165) you may need to clean `yarn`'s cache with `yarn cache clean` before.)
- Run the app with `react-native-cli`: `react-native run-ios`

Expand Down
1 change: 1 addition & 0 deletions ios/RCTPSPDFKit/Converters/RCTConvert+PSPDFConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#import <React/RCTConvert.h>
@import PSPDFKit;
@import PSPDFKitUI;

@interface RCTConvert (PSPDFConfiguration)

Expand Down
72 changes: 38 additions & 34 deletions ios/RCTPSPDFKit/Converters/RCTConvert+PSPDFConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ + (PSPDFConfiguration *)PSPDFConfiguration:(id)json {
NSDictionary *dictionary = [self NSDictionary:json];

return [PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder * _Nonnull builder) {
SET(margin, UIEdgeInsets)
SET(padding, UIEdgeInsets)
SET(pagePadding, CGFloat)
SET(doubleTapAction, PSPDFTapAction)
SET(formElementZoomEnabled, BOOL)
SET(scrollOnTapPageEndEnabled, BOOL)
Expand All @@ -37,16 +34,15 @@ + (PSPDFConfiguration *)PSPDFConfiguration:(id)json {
SET(bookmarkSortOrder, PSPDFBookmarkManagerSortOrder)
SET(internalTapGesturesEnabled, BOOL)
SET(useParentNavigationBar, BOOL)
SET(shouldRestoreNavigationBarStyle, BOOL)
SET(linkAction, PSPDFLinkAction)
SET(allowedMenuActions, PSPDFTextSelectionMenuAction)
SET(HUDViewMode, PSPDFHUDViewMode)
SET(HUDViewAnimation, PSPDFHUDViewAnimation)
SET(userInterfaceViewMode, PSPDFUserInterfaceViewMode)
SET(userInterfaceViewAnimation, PSPDFUserInterfaceViewAnimation)
SET(thumbnailBarMode, PSPDFThumbnailBarMode)
SET(pageLabelEnabled, BOOL)
SET(documentLabelEnabled, PSPDFAdaptiveConditional)
SET(shouldHideHUDOnPageChange, BOOL)
SET(shouldShowHUDOnViewWillAppear, BOOL)
SET(shouldHideUserInterfaceOnPageChange, BOOL)
SET(shouldShowUserInterfaceOnViewWillAppear, BOOL)
SET(allowToolbarTitleChange, BOOL)
SET(renderAnimationEnabled, BOOL)
SET(renderStatusViewPosition, PSPDFRenderStatusViewPosition)
Expand All @@ -56,22 +52,16 @@ + (PSPDFConfiguration *)PSPDFConfiguration:(id)json {
SET(pageTransition, PSPDFPageTransition)
SET(scrollDirection, PSPDFScrollDirection)
SET(scrollViewInsetAdjustment, PSPDFScrollInsetAdjustment)
SET(doublePageModeOnFirstPage, BOOL)
SET(zoomingSmallDocumentsEnabled, BOOL)
SET(pageCurlDirectionLeftToRight, BOOL)
SET(fitToWidthEnabled, BOOL)
SET(showsHorizontalScrollIndicator, BOOL)
SET(showsVerticalScrollIndicator, BOOL)
SET(alwaysBouncePages, BOOL)
SET(fixedVerticalPositionForFitToWidthEnabledMode, BOOL)
SET(firstPageAlwaysSingle, BOOL)
SET(spreadFitting, PSPDFConfigurationSpreadFitting)
SET(clipToPageBoundaries, BOOL)
SET(minimumZoomScale, float)
SET(maximumZoomScale, float)
SET(shadowEnabled, BOOL)
SET(shadowOpacity, CGFloat)
SET(shouldHideNavigationBarWithHUD, BOOL)
SET(shouldHideNavigationBarWithUserInterface, BOOL)
SET(shouldHideStatusBar, BOOL)
SET(shouldHideStatusBarWithHUD, BOOL)
SET(shouldHideStatusBarWithUserInterface, BOOL)
SET(backgroundColor, UIColor)
SET(allowedAppearanceModes, PSPDFAppearanceMode)
SET(thumbnailSize, CGSize)
Expand All @@ -93,8 +83,7 @@ + (PSPDFConfiguration *)PSPDFConfiguration:(id)json {
SET(shouldScrollToChangedPage, BOOL)
SET(searchMode, PSPDFSearchMode)
SET(searchResultZoomScale, CGFloat)
SET(signatureSavingEnabled, BOOL)
SET(customerSignatureFeatureEnabled, BOOL)
SET(signatureSavingStrategy, PSPDFSignatureSavingStrategy)
SET(naturalSignatureDrawingEnabled, BOOL)
// currently unsupported: SET(*galleryConfiguration, PSPDFGalleryConfiguration)
SET(showBackActionButton, BOOL)
Expand Down Expand Up @@ -139,23 +128,23 @@ + (PSPDFConfiguration *)PSPDFConfiguration:(id)json {
@"alertView" : @(PSPDFLinkActionAlertView),
@"openSafari" : @(PSPDFLinkActionOpenSafari),
@"inlineBrowser" : @(PSPDFLinkActionInlineBrowser),
@"browserLegacy" : @(PSPDFLinkActionInlineBrowserLegacy)}),
@"InlineWebViewController" : @(PSPDFLinkActionInlineWebViewController)}),
PSPDFLinkActionNone,
unsignedIntegerValue)

RCT_ENUM_CONVERTER(PSPDFHUDViewMode,
(@{@"always" : @(PSPDFHUDViewModeAlways),
@"automatic" : @(PSPDFHUDViewModeAutomatic),
@"automaticNoFirstLastPage" : @(PSPDFHUDViewModeAutomaticNoFirstLastPage),
@"never" : @(PSPDFHUDViewModeNever)}),
PSPDFHUDViewModeAutomatic,
RCT_ENUM_CONVERTER(PSPDFUserInterfaceViewMode,
(@{@"always" : @(PSPDFUserInterfaceViewModeAlways),
@"automatic" : @(PSPDFUserInterfaceViewModeAutomatic),
@"automaticNoFirstLastPage" : @(PSPDFUserInterfaceViewModeAutomaticNoFirstLastPage),
@"never" : @(PSPDFUserInterfaceViewModeNever)}),
PSPDFUserInterfaceViewModeAutomatic,
unsignedIntegerValue)

RCT_ENUM_CONVERTER(PSPDFHUDViewAnimation,
(@{@"none" : @(PSPDFHUDViewAnimationNone),
@"fade" : @(PSPDFHUDViewAnimationFade),
@"slide" : @(PSPDFHUDViewAnimationSlide)}),
PSPDFHUDViewAnimationNone,
RCT_ENUM_CONVERTER(PSPDFUserInterfaceViewAnimation,
(@{@"none" : @(PSPDFUserInterfaceViewAnimationNone),
@"fade" : @(PSPDFUserInterfaceViewAnimationFade),
@"slide" : @(PSPDFUserInterfaceViewAnimationSlide)}),
PSPDFUserInterfaceViewAnimationNone,
unsignedIntegerValue)

RCT_ENUM_CONVERTER(PSPDFThumbnailBarMode,
Expand Down Expand Up @@ -200,10 +189,10 @@ + (PSPDFConfiguration *)PSPDFConfiguration:(id)json {
unsignedIntegerValue)

RCT_ENUM_CONVERTER(PSPDFPageTransition,
(@{@"scrollPerPage" : @(PSPDFPageTransitionScrollPerPage),
(@{@"scrollPerSpread" : @(PSPDFPageTransitionScrollPerSpread),
@"scrollContinuous" : @(PSPDFPageTransitionScrollContinuous),
@"curl" : @(PSPDFPageTransitionCurl)}),
PSPDFPageTransitionScrollPerPage,
PSPDFPageTransitionScrollPerSpread,
unsignedIntegerValue)

RCT_ENUM_CONVERTER(PSPDFScrollInsetAdjustment,
Expand All @@ -225,6 +214,13 @@ + (PSPDFConfiguration *)PSPDFConfiguration:(id)json {
PSPDFSearchModeModal,
unsignedIntegerValue)

RCT_ENUM_CONVERTER(PSPDFSignatureSavingStrategy,
(@{@"alwaysSave" : @(PSPDFSignatureSavingStrategyAlwaysSave),
@"neverSave" : @(PSPDFSignatureSavingStrategyNeverSave),
@"saveIfSelected" : @(PSPDFSignatureSavingStrategySaveIfSelected)}),
PSPDFSignatureSavingStrategyAlwaysSave,
unsignedIntegerValue)

RCT_MULTI_ENUM_CONVERTER(PSPDFAnnotationType,
(@{@"none" : @(PSPDFAnnotationTypeNone),
@"undefined" : @(PSPDFAnnotationTypeUndefined),
Expand Down Expand Up @@ -300,4 +296,12 @@ + (PSPDFConfiguration *)PSPDFConfiguration:(id)json {
PSPDFSettingsOptionAll,
unsignedIntegerValue)

RCT_ENUM_CONVERTER(PSPDFConfigurationSpreadFitting,
(@{@"fit" : @(PSPDFConfigurationSpreadFittingFit),
@"fill" : @(PSPDFConfigurationSpreadFittingFill),
@"adaptive" : @(PSPDFConfigurationSpreadFittingAdaptive)}),
PSPDFScrollInsetAdjustmentNone,
unsignedIntegerValue)

@end

1 change: 1 addition & 0 deletions ios/RCTPSPDFKit/Converters/RCTConvert+PSPDFDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#import <React/RCTConvert.h>
@import PSPDFKit;
@import PSPDFKitUI;

@interface RCTConvert (PSPDFDocument)

Expand Down
2 changes: 1 addition & 1 deletion ios/RCTPSPDFKit/Converters/RCTConvert+PSPDFDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ + (PSPDFDocument *)PSPDFDocument:(NSString *)string {
url = [[NSBundle mainBundle] URLForResource:string withExtension:nil];
}

return [PSPDFDocument documentWithURL:url];
return [[PSPDFDocument alloc] initWithURL:url];
}

@end
1 change: 1 addition & 0 deletions ios/RCTPSPDFKit/RCTPSPDFKitManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import <React/RCTConvert.h>

@import PSPDFKit;
@import PSPDFKitUI;

@implementation RCTPSPDFKitManager

Expand Down
14 changes: 7 additions & 7 deletions ios/cocoapods.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
### CocoaPods integration

#### Requirements
- Xcode 8.3.3
- PSPDFKit >=6.9.3
- react-native >= 0.48.1
- Xcode 9
- PSPDFKit >=7.0.0
- react-native >= 0.48.4
- CocoaPods >= 1.3.1

#### Getting Started

Lets create a simple app that integrates `PSPDFKit.framework` using CocoaPods.
Lets create a simple app that integrates PSPDFKit using CocoaPods.

1. Make sure `react-native-cli` is installed: `yarn global add react-native-cli`
2. Create the app with `react-native init YourApp`.
3. Step into your newly created app folder: `cd YourApp`
4. Install `react-native-pspdfkit` from GitHub: `yarn add github:PSPDFKit/react-native`
5. IMPORTANT: Do not link module react-native-pspdfkit: Do not use react-native link react-native-pspdfkit
6. Create the folder `ios/PSPDFKit` and copy `PSPDFKit.framework` into it.
6. Create the folder `ios/PSPDFKit` and copy `PSPDFKit.framework` and `PSPDFKitUI.framework` into it.
7. Open ios/YourApp.xcodeproj in Xcode: open ios/YourApp.xcodeproj
8. Make sure the deployment target is set to 9.0 or higher:
![Deployment Target](../screenshots/deployment-target.png)
Expand Down Expand Up @@ -55,12 +55,12 @@ end

13. Run `pod install`
14. Open the newly created workspace: `YourApp.workspace`
15. Copy `PSPDFKit.framework` into the Pods folder: `YourApp/ios/Pods`
15. Copy `PSPDFKit.framework` and `PSPDFKitUI.framework` into the Pods folder: `YourApp/ios/Pods`
16. Drag and drop it from the Finder into the `RCTPSPDFKit` group:
![Deployment Target](../screenshots/embedding-pspdfkit-pods.png)
17. Add it to the `react-native-pspdfkit` framework:
![Deployment Target](../screenshots/adding-to-react-native-pspdfkit.png)
18. Embed `YourApp/ios/PSPDFKit/PSPDFKit.framework` (not the copy from `YourApp/ios/Pods/PSPDFKit.framework`) by drag and dropping it into the "Embedded Binaries" section of the "YourApp" target (Select "Create groups"). This will also add it to the "Linked Frameworks and Libraries" section:
18. Embed `YourApp/ios/PSPDFKit/PSPDFKit.framework` and `YourApp/ios/PSPDFKit/PSPDFKitUI.framework` (not the copies from `YourApp/ios/Pods/`) by drag and dropping it into the "Embedded Binaries" section of the "YourApp" target (Select "Create groups"). This will also add it to the "Linked Frameworks and Libraries" section:
![Embedding PSPDFKit](../screenshots/embedding-pspdfkit.png)
19. Add a PDF by drag and dropping it into your Xcode project (Select "Create groups" and add to target "YourApp"). This will add the document to the "Copy Bundle Resources" build phase:
![Adding PDF](../screenshots/adding-pdf.png)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-pspdfkit",
"version": "1.4.0",
"version": "1.5.0",
"description": "A React Native module for the PSPDFKit library.",
"keywords": [
"react native",
Expand Down
2 changes: 1 addition & 1 deletion samples/Catalog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "0.48.1",
"react-native": "0.48.4",
"react-native-fs": "github:johanneslumpe/react-native-fs#55dd2a7624f4617e04a895a9a319cb012c1002a5",
"react-native-pspdfkit": "file:../../"
}
Expand Down
Binary file modified screenshots/adding-pdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/embedding-pspdfkit-pods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/embedding-pspdfkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fddc242

Please sign in to comment.