5
5
// Created by Extrieve Technologies Pvt Ltd on 14/06/23.
6
6
//
7
7
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
+
8
16
#import " ViewController.h"
9
17
10
18
11
19
#ifdef RELEASE
12
- // For CameraHelper Support
20
+ // / Necessary For CameraHelper Support
13
21
#import " ../../Build/Products/Release-iphoneos/QuickCaptureSDK.framework/Headers/QuickCaptureSDK-Swift.h"
14
- // For ImgHelperSupport
22
+ // / Necessary For ImgHelper Support
15
23
#import " ../../Build/Products/Release-iphoneos/QuickCaptureSDK.framework/Headers/QuickCaptureFW.h"
16
24
#else
17
- // For CameraHelper Support
25
+ // / Necessary For CameraHelper Support
18
26
#import " ../../Build/Products/Debug-iphoneos/QuickCaptureSDK.framework/Headers/QuickCaptureSDK-Swift.h"
19
- // For ImgHelperSupport
27
+ // / Necessary For ImgHelper Support
20
28
#import " ../../Build/Products/Debug-iphoneos/QuickCaptureSDK.framework/Headers/QuickCaptureFW.h"
21
29
22
30
#endif
23
31
24
- typedef void (^CaptureCallbackBlock)(NSArray <NSString *> * _Nonnull imageArray);
25
-
26
-
27
32
33
+ typedef void (^CaptureCallbackBlock)(NSArray <NSString *> * _Nonnull imageArray);
28
34
29
35
@interface ViewController ()
30
36
@property (nonatomic , copy , nullable ) CaptureCallbackBlock captureCallback;
31
-
37
+ @property __block NSArray <NSString *> *CapturedImages;
32
38
@end
33
39
34
40
@implementation ViewController
35
41
36
42
37
- - (void ) CallbackForCaptureCB : (NSArray <NSString *> *) imageArray
38
- {
39
- return ;
40
- }
41
43
42
44
43
45
- (IBAction )btnLaunchCameraTap : (id )sender {
44
46
45
-
46
-
47
47
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES );
48
48
49
49
NSString *directory = [[[[NSFileManager defaultManager ] URLsForDirectory: NSDocumentDirectory inDomains: NSUserDomainMask] firstObject ] absoluteString ];
@@ -54,64 +54,109 @@ - (IBAction)btnLaunchCameraTap:(id)sender {
54
54
}
55
55
56
56
57
+ // /Some Configurations before starting the Camera Capture
58
+ // /The camera Capture session will behave according to these settings
57
59
NSURL *workingDirUrl = [url URLByAppendingPathComponent: @" QuickCaptureDemoWorking1" ];
58
60
CaptureSupport.OutputPath = [workingDirUrl absoluteString ];
59
61
CaptureSupport.CaptureSound = true ;
62
+ CaptureSupport.ColorMode = ColorModesRGB;
63
+ CaptureSupport.CameraToggle = 2 ;
64
+ CaptureSupport.EnableFlash = false ;
60
65
61
66
62
- NSString *documentDir = [paths firstObject ];
67
+ NSString *workingDir = [paths firstObject ];
63
68
64
69
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
66
72
self.captureCallback = ^(NSArray <NSString *> * _Nonnull imageArray) {
67
73
if (imageArray.count == 0 ) {
68
74
NSLog (@" Error: no images found" );
69
75
}
70
76
else {
71
- NSLog (@" %lu " , (unsigned long )imageArray.count );
72
- BOOL isExist = [NSFileManager .defaultManager fileExistsAtPath: imageArray[0 ]];
73
-
74
- ImgHelper *img = [ImgHelper GetInstance ];
75
77
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;
105
82
}
106
83
};
107
84
85
+ // /Instanciating the CameraHelper Class to use its properties
108
86
CameraHelper *cameraHelperObj = [[CameraHelper alloc ] init ];
109
87
110
88
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];
113
92
}
114
93
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
+
115
160
- (void )viewDidLoad {
116
161
[super viewDidLoad ];
117
162
NSString *Directory = [[[NSFileManager defaultManager ] URLsForDirectory: NSDocumentDirectory inDomains: NSUserDomainMask] firstObject ].absoluteString ;
0 commit comments