Skip to content

Commit 67cc231

Browse files
sample obj-c app updates
updated sample app with proper comments
1 parent bf2ff50 commit 67cc231

File tree

3 files changed

+106
-52
lines changed

3 files changed

+106
-52
lines changed

Objective-C_sample/TestObjcApp.xcodeproj/xcshareddata/xcschemes/TestObjcApp.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</Testables>
3232
</TestAction>
3333
<LaunchAction
34-
buildConfiguration = "Release"
34+
buildConfiguration = "Debug"
3535
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3636
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
3737
launchStyle = "0"

Objective-C_sample/TestObjcApp/Base.lproj/Main.storyboard

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333
<nil key="textColor"/>
3434
<nil key="highlightedColor"/>
3535
</label>
36+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xiU-Yu-LKc">
37+
<rect key="frame" x="102" y="537" width="164" height="35"/>
38+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
39+
<state key="normal" title="Button"/>
40+
<buttonConfiguration key="configuration" style="plain" title="Action"/>
41+
<connections>
42+
<action selector="btnActionTap:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ic6-tX-Z4A"/>
43+
</connections>
44+
</button>
3645
</subviews>
3746
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
3847
<color key="backgroundColor" systemColor="systemBackgroundColor"/>

Objective-C_sample/TestObjcApp/ViewController.m

Lines changed: 96 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,45 @@
55
// Created by Extrieve Technologies Pvt Ltd on 14/06/23.
66
//
77

8+
///Framework contains two Header file which is Necessary to import
9+
/// QuickCaptureSDK-Swift.h and QuickCaptureFW.h
10+
/// Inside the Framework Package you will find under the Header Folder
11+
///
12+
/// import "<Path to Framework>/QuickCaptureSDK.framework/Headers/QuickCaptureSDK-Swift.h"
13+
/// import "<Path to Framework>/QuickCaptureSDK.framework/Headers/QuickCaptureFW.h"
14+
15+
816
#import "ViewController.h"
917

1018

1119
#ifdef RELEASE
12-
//For CameraHelper Support
20+
/// Necessary For CameraHelper Support
1321
#import "../../Build/Products/Release-iphoneos/QuickCaptureSDK.framework/Headers/QuickCaptureSDK-Swift.h"
14-
//For ImgHelperSupport
22+
/// Necessary For ImgHelper Support
1523
#import "../../Build/Products/Release-iphoneos/QuickCaptureSDK.framework/Headers/QuickCaptureFW.h"
1624
#else
17-
//For CameraHelper Support
25+
/// Necessary For CameraHelper Support
1826
#import "../../Build/Products/Debug-iphoneos/QuickCaptureSDK.framework/Headers/QuickCaptureSDK-Swift.h"
19-
//For ImgHelperSupport
27+
/// Necessary For ImgHelper Support
2028
#import "../../Build/Products/Debug-iphoneos/QuickCaptureSDK.framework/Headers/QuickCaptureFW.h"
2129

2230
#endif
2331

24-
typedef void (^CaptureCallbackBlock)(NSArray<NSString *> * _Nonnull imageArray);
25-
26-
2732

33+
typedef void (^CaptureCallbackBlock)(NSArray<NSString *> * _Nonnull imageArray);
2834

2935
@interface ViewController ()
3036
@property (nonatomic, copy, nullable) CaptureCallbackBlock captureCallback;
31-
37+
@property __block NSArray<NSString *> *CapturedImages;
3238
@end
3339

3440
@implementation ViewController
3541

3642

37-
- (void) CallbackForCaptureCB:(NSArray<NSString *> *) imageArray
38-
{
39-
return;
40-
}
4143

4244

4345
- (IBAction)btnLaunchCameraTap:(id)sender {
4446

45-
46-
4747
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
4848

4949
NSString *directory = [[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject] absoluteString];
@@ -54,64 +54,109 @@ - (IBAction)btnLaunchCameraTap:(id)sender {
5454
}
5555

5656

57+
///Some Configurations before starting the Camera Capture
58+
///The camera Capture session will behave according to these settings
5759
NSURL *workingDirUrl = [url URLByAppendingPathComponent:@"QuickCaptureDemoWorking1"];
5860
CaptureSupport.OutputPath = [workingDirUrl absoluteString];
5961
CaptureSupport.CaptureSound = true;
62+
CaptureSupport.ColorMode = ColorModesRGB;
63+
CaptureSupport.CameraToggle = 2;
64+
CaptureSupport.EnableFlash = false;
6065

6166

62-
NSString *documentDir = [paths firstObject];
67+
NSString *workingDir = [paths firstObject];
6368

6469

65-
//Handling the captured images in this callback function
70+
///This callback will be Required for CameraHelper.StartCapture as an argument.
71+
///This will be called after the Capture Session is closed
6672
self.captureCallback = ^(NSArray<NSString *> * _Nonnull imageArray) {
6773
if (imageArray.count == 0) {
6874
NSLog(@"Error: no images found");
6975
}
7076
else{
71-
NSLog(@"%lu", (unsigned long)imageArray.count);
72-
BOOL isExist = [NSFileManager.defaultManager fileExistsAtPath:imageArray[0]];
73-
74-
ImgHelper *img = [ImgHelper GetInstance];
7577

76-
NSURL *workingDirURL = [NSURL URLWithString:CaptureSupport.OutputPath];
77-
if (!workingDirURL) {
78-
return;
79-
}
80-
81-
NSFileManager *manager = [NSFileManager defaultManager];
82-
BOOL isDirectory = NO;
83-
if (![manager fileExistsAtPath:workingDirURL.path isDirectory:&isDirectory] || !isDirectory) {
84-
NSError *error = nil;
85-
[manager createDirectoryAtPath:workingDirURL.path withIntermediateDirectories:YES attributes:nil error:&error];
86-
if (error) {
87-
NSLog(@"Unable to create output directory");
88-
}
89-
}
90-
91-
NSURL *outputTiffURL = [workingDirURL URLByAppendingPathComponent:@"OutputPDF.JPEG"];
92-
NSError * _Nullable err;
93-
94-
[img SetDpi:DPI_100];
95-
[img setPageLayout:LayoutTypeA0];
96-
97-
UIImage* thumb = [img CompressAndGetThumbnail:imageArray[0] outputURI:outputTiffURL.absoluteString err:&err];
98-
//UIImage* thumb = [img CompressAndGetThumbnailWithInputURI:imageArray[0] outputURI:outputTiffURL.absoluteString error:&err];
99-
NSLog(@"%@",err.description);
100-
NSLog(@"%@",err.localizedDescription);
101-
102-
int ret = [img createPdfFileFromJpegArray:workingDirUrl.path :imageArray :outputTiffURL.path :200 :200 :40];
103-
104-
NSLog(@"%d",ret);
78+
///imageArray is the Argument where you get the Array od Strings
79+
///these strings are the path of captured image saved in WorkingDirectory temporarily
80+
///Note: Don't forget to delete image files after completion of task
81+
self->_CapturedImages = imageArray;
10582
}
10683
};
10784

85+
///Instanciating the CameraHelper Class to use its properties
10886
CameraHelper *cameraHelperObj = [[CameraHelper alloc] init];
10987

11088

111-
//Start Capturing the Images from Camera using Framework
112-
[cameraHelperObj StartCapture:self :documentDir : self.captureCallback];
89+
///Start Capturing the Images from Camera using Framework
90+
///It will save all the Captured images
91+
[cameraHelperObj StartCapture:self :workingDir : self.captureCallback];
11392
}
11493

94+
95+
96+
///This button tap Action is providing the Usage of ImageHelper Class Properties
97+
- (IBAction)btnActionTap:(id)sender{
98+
99+
100+
NSLog(@"%lu", (unsigned long)self->_CapturedImages.count);
101+
BOOL isExist = [NSFileManager.defaultManager fileExistsAtPath:self->_CapturedImages[0]];
102+
103+
104+
NSURL *workingDirURL = [NSURL URLWithString:CaptureSupport.OutputPath];
105+
if (!workingDirURL) {
106+
return;
107+
}
108+
109+
NSFileManager *manager = [NSFileManager defaultManager];
110+
BOOL isDirectory = NO;
111+
if (![manager fileExistsAtPath:workingDirURL.path isDirectory:&isDirectory] || !isDirectory) {
112+
NSError *error = nil;
113+
[manager createDirectoryAtPath:workingDirURL.path withIntermediateDirectories:YES attributes:nil error:&error];
114+
if (error) {
115+
NSLog(@"Unable to create output directory");
116+
}
117+
}
118+
119+
NSURL *outputTiffURL = [workingDirURL URLByAppendingPathComponent:@"OutputPDF.JPEG"];
120+
NSError * _Nullable err;
121+
122+
123+
///Instanciating the ImgHelper class using GetInstance Method
124+
ImgHelper *img = [ImgHelper GetInstance];
125+
126+
///Setting the DPI as 100 using SetDpi method which takes enum value as an argument
127+
[img SetDpi:DPI_100];
128+
129+
///Setting the PageLayout as A4 using setPageLayout method which takes enum value as an argument
130+
[img setPageLayout:LayoutTypeA4];
131+
132+
133+
///CompressAndGetThumbnail : This method Returns an UIImage object which is THumbnail of the image path passed as an argument
134+
///It saves the compressed image on outputURI path
135+
///Last argument "err" is for any excceptions occurs
136+
///Note: Here we are providing the AbsoluteString as it take the FullPath to save the image
137+
UIImage* thumb = [img CompressAndGetThumbnail:self->_CapturedImages[0] outputURI:outputTiffURL.absoluteString err:&err];
138+
NSLog(@"%@",err.description);
139+
NSLog(@"%@",err.localizedDescription);
140+
141+
///Getting the ImageQuality
142+
int quality = [img getJPEGQuality];
143+
144+
///createPdfFileFromJpegArray : This method will create a PDF out of Images provided by the NSArray of NSString saves the pdf file in outputTiffURL provided as String
145+
///First argument is working directory it should be readable and writeable directory where this function saves some temporary data then removes after completion
146+
///Return Integer value as 0 means TRUE or success and vice versa
147+
int ret = [img createPdfFileFromJpegArray:workingDirURL.path :self->_CapturedImages :outputTiffURL.path :DPI_200 :DPI_200 :quality];
148+
149+
NSLog(@"%d",ret);
150+
151+
152+
153+
154+
}
155+
156+
157+
158+
159+
115160
- (void)viewDidLoad {
116161
[super viewDidLoad];
117162
NSString *Directory = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject].absoluteString;

0 commit comments

Comments
 (0)