Skip to content

Commit

Permalink
- Better handling of PDF / UIImage generation for large PDF. (We now …
Browse files Browse the repository at this point in the history
…generate the 1st page and generate all other pages on a background thread)

- Updated Documentation/Tutorials
- Overall, fastest performance
  • Loading branch information
charlymr committed Nov 7, 2021
1 parent 21c1897 commit 6ea9046
Show file tree
Hide file tree
Showing 454 changed files with 1,041 additions and 593 deletions.
2 changes: 1 addition & 1 deletion Demo-Carthage/CartFile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "charlymr/IRLPDFScanContent" ~> 1.0.1
github "charlymr/IRLPDFScanContent" ~> 1.0.2
2 changes: 1 addition & 1 deletion Demo-Carthage/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "charlymr/IRLPDFScanContent" "1.0.1"
github "charlymr/IRLPDFScanContent" "1.0.2"
6 changes: 4 additions & 2 deletions Demo-Carthage/IRLPDFScanDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,15 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 6CHEU74FHQ;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = IRLPDFScanDemo/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -345,14 +346,15 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 6CHEU74FHQ;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = IRLPDFScanDemo/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
5 changes: 2 additions & 3 deletions Demo-Carthage/IRLPDFScanDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ class ViewController: UIViewController {
extension ViewController: IRLPDFScanContentProtocol {

func scanContent(caller: IRLPDFScanContent, didScan scan: VNDocumentCameraScan) {
guard let url = caller.generatePDF() else {
guard let document = scan.generatePDFDocument(pdfView: self.pdfView) else {
return
}
view.sendSubviewToBack(text)
pdfView.document = PDFDocument(url: url)
pdfView.autoScales = true
pdfView.document = document
}

func scanContent(caller: IRLPDFScanContent, didFail error: Error) {
Expand Down
28 changes: 6 additions & 22 deletions Demo-Cocoapods/IRLPDFScanDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
51957C761A629DEA33ADEFEF /* Pods_IRLPDFScanDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6992577AD2889AFE6A45729C /* Pods_IRLPDFScanDemo.framework */; };
02BF96B9A3344DC9A817AFB5 /* libPods-IRLPDFScanDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 396D1C721C13234B9E210AEC /* libPods-IRLPDFScanDemo.a */; };
618D33812736F30A00853801 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618D33802736F30A00853801 /* AppDelegate.swift */; };
618D33832736F30A00853801 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618D33822736F30A00853801 /* SceneDelegate.swift */; };
618D33852736F30A00853801 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618D33842736F30A00853801 /* ViewController.swift */; };
Expand All @@ -17,6 +17,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
396D1C721C13234B9E210AEC /* libPods-IRLPDFScanDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-IRLPDFScanDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
618D337D2736F30A00853801 /* IRLPDFScanDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IRLPDFScanDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
618D33802736F30A00853801 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
618D33822736F30A00853801 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -25,7 +26,6 @@
618D33892736F30C00853801 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
618D338C2736F30C00853801 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
618D338E2736F30C00853801 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6992577AD2889AFE6A45729C /* Pods_IRLPDFScanDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_IRLPDFScanDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EA274B063754233A3807A551 /* Pods-IRLPDFScanDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IRLPDFScanDemo.debug.xcconfig"; path = "Target Support Files/Pods-IRLPDFScanDemo/Pods-IRLPDFScanDemo.debug.xcconfig"; sourceTree = "<group>"; };
EB0ACB07DE388B66E2EE57DF /* Pods-IRLPDFScanDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IRLPDFScanDemo.release.xcconfig"; path = "Target Support Files/Pods-IRLPDFScanDemo/Pods-IRLPDFScanDemo.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -35,7 +35,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
51957C761A629DEA33ADEFEF /* Pods_IRLPDFScanDemo.framework in Frameworks */,
02BF96B9A3344DC9A817AFB5 /* libPods-IRLPDFScanDemo.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -86,7 +86,7 @@
CCB4F3FCFA836269346A5644 /* Frameworks */ = {
isa = PBXGroup;
children = (
6992577AD2889AFE6A45729C /* Pods_IRLPDFScanDemo.framework */,
396D1C721C13234B9E210AEC /* libPods-IRLPDFScanDemo.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand All @@ -102,7 +102,6 @@
618D33792736F30A00853801 /* Sources */,
618D337A2736F30A00853801 /* Frameworks */,
618D337B2736F30A00853801 /* Resources */,
6C304774A99F80482E0B2119 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -182,23 +181,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
6C304774A99F80482E0B2119 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-IRLPDFScanDemo/Pods-IRLPDFScanDemo-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-IRLPDFScanDemo/Pods-IRLPDFScanDemo-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-IRLPDFScanDemo/Pods-IRLPDFScanDemo-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -366,6 +348,7 @@
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -395,6 +378,7 @@
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
5 changes: 2 additions & 3 deletions Demo-Cocoapods/IRLPDFScanDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ class ViewController: UIViewController {
extension ViewController: IRLPDFScanContentProtocol {

func scanContent(caller: IRLPDFScanContent, didScan scan: VNDocumentCameraScan) {
guard let url = caller.generatePDF() else {
guard let document = scan.generatePDFDocument(pdfView: self.pdfView) else {
return
}
view.sendSubviewToBack(text)
pdfView.document = PDFDocument(url: url)
pdfView.autoScales = true
pdfView.document = document
}

func scanContent(caller: IRLPDFScanContent, didFail error: Error) {
Expand Down
16 changes: 0 additions & 16 deletions Demo-Cocoapods/Podfile.lock

This file was deleted.

2 changes: 2 additions & 0 deletions Demo/IRLScanDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -333,6 +334,7 @@
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
17 changes: 5 additions & 12 deletions Demo/IRLScanDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,22 @@ import IRLPDFScanContent
struct ContentView: View {

@ObservedObject var scanner: IRLPDFScanContent = IRLPDFScanContent()

@State var pdfView: IRLPDFView? = nil


var body: some View {
NavigationView {
VStack() {
if let pdfView = pdfView {
pdfView
if let latestScan = scanner.latestScan {
latestScan.swiftUIPDFView

} else {
Text("Press the Scan button")
}
}
.padding()
.navigationBarItems(trailing: Button("Scan", action: {
Task {
await scanner.present(animated: true)
}
scanner.present(animated: true, completion: nil)
}))
.onChange(of: scanner.latestScan) { newValue in
pdfView = newValue?.swiftUIPDFView
}
}

}
}

Expand Down
4 changes: 2 additions & 2 deletions IRLPDFScanContent.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
Pod::Spec.new do |s|

s.name = "IRLPDFScanContent"
s.version = "1.0.1"
s.version = "1.0.2"
s.summary = "SwiftUI & UKKit - Images or PDF scanner."
s.description = "A convenient class usable from `UIKit` view controller or `SwiftUI` to scan document & get `UIImage` or `PDFDocument` as result"
s.license = { :type => 'MIT', :file => 'LICENSE' }

s.homepage = "https://github.com/charlymr/IRLPDFScanContent"
s.authors = { 'Denis Martin' => 'support@irlmobile.com' }
s.source = { :git => 'https://github.com/charlymr/IRLPDFScanContent.git', :branch => 'main', :tag => '1.0.1'}
s.source = { :git => 'https://github.com/charlymr/IRLPDFScanContent.git', :branch => 'main', :tag => '1.0.2'}

s.platform = :ios, '13.0'

Expand Down
8 changes: 4 additions & 4 deletions IRLPDFScanContent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -325,7 +325,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 1.0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.irlmobile.IRLPDFScanContent;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand All @@ -340,7 +340,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -355,7 +355,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 1.0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.irlmobile.IRLPDFScanContent;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
44 changes: 32 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ Please add the following to your plist:

## Install

### via Swift Package (With Documentation)
### Swift Package
Integrate the library via Swift Package (With Documentation)

Add the Package to your project, min version `5.5`, See [Apple Documentation](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app).
#### In Xcode

Add the Package to your project, min version `5.5`, See [Apple Documentation](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app) for more details.

#### Manually

Create a Package.swift in a folder, then Drop the file on Xcode

```swift
// swift-tools-version:5.5
Expand All @@ -34,7 +41,7 @@ let package = Package(
targets: ["SPMDemo"]),
],
dependencies: [
.package(url: "git@github.com:charlymr/IRLPDFScanContent.git", from: "1.0.0"),
.package(url: "git@github.com:charlymr/IRLPDFScanContent.git", from: "1.0.2"),
],
targets: [
.target( name: "SPMDemo",
Expand All @@ -45,16 +52,19 @@ let package = Package(
)
```

### via CocoaPods
### CocoaPods
Integrate the library via CocoaPods

Install CocoaPods if not already available:
#### Install CocoaPods
if not already available:

``` bash
$ [sudo] gem install cocoapods
$ pod setup
```

Change to the directory of your Xcode project, and Create and Edit your Podfile and add IRLPDFScanContent:
#### Update your Podfile
Change to the directory of your Xcode project, and Create and Edit your Podfile and add ``IRLPDFScanContent``:

``` bash
$ cd /path/to/MyProject
Expand All @@ -69,27 +79,37 @@ target "YOUR APP" do
end
```

### via Carthage
#### Prepare project
run `pod update` or `pod install` to generate the Workspace

``` bash
$ pod update
```

### Carthage
Integrate the library via Carthage.
For more details on Cartage and how to use it, check the [Carthage Github](https://github.com/Carthage/Carthage) documentation

#### Install Carthage
Install [Carthage](https://github.com/Carthage/Carthage#installing-carthage) if not already available

Change to the directory of your Xcode project, and Create and Edit your Podfile and add IRLPDFScanContent:
#### Update your CartFile
Change to the directory of your Xcode project, and Create and Edit your CartFile and add [``IRLPDFScanContent``](https://irlpdfscancontent.irlmobile.com/documentation/):

``` bash
$ cd /path/to/MyProject
$ touch CartFile
## edit CartFile:

github "charlymr/IRLPDFScanContent" ~> 1.0.1
github "charlymr/IRLPDFScanContent" ~> 1.0.2
```

Save and run:
#### Prepare
``` bash
$ carthage update --use-xcframeworks
```
Drop the Carthage/Build/iOS .framework in your project.
Drop the Carthage/Build/iOS `.xcframework` in your project.

For more details on Cartage and how to use it, check the [Carthage Github](https://github.com/Carthage/Carthage) documentation

## [Getting started](https://irlpdfscancontent.irlmobile.com)

Expand Down
4 changes: 3 additions & 1 deletion Sources/IRLPDFScanContent/Exports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ public enum IRLPDFScanContentVersion: String {

/// Patch Versions
case v1_0_0 = "1.0.0"

case v1_0_1 = "1.0.1"
case v1_0_2 = "1.0.2"

}
4 changes: 2 additions & 2 deletions Sources/IRLPDFScanContent/IRLPDFScanContent.docc/About.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This project is Open source. It comes with no warranty or support.

## Overview

Of course, like any open source project, feel free to fork and modify this code. Pull requests are more than welcome! That is the core of Open source projects!
Of course, like any open source project, feel free to fork and modify this code. Pull requests are more than welcome! That is the core of Open source projects! You take and give back!

- Warning: Please do not create an issue without first trying to solve it and respect the free time I put on this. I tend to really dislike when I am ordered to fix an issue while the source code is all available & documented. If you need a solution with support & warranties, please check with a vendor not on Github for open source projects.
- Warning: Please do not create an issue without first trying to solve it and respect the free time I & fellow contributors put on this. I tend to really dislike when I am ordered to fix an issue while the source code is all available & documented. If you need a solution with support & warranties, please check with a vendor not on Github for open source projects.

### MIT License

Expand Down
Loading

0 comments on commit 6ea9046

Please sign in to comment.