├── .gitignore ├── ImageToPDF.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── ImageToPDF ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── LICENSE ├── README.md └── img ├── img1.png └── img2.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /ImageToPDF.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 94181B1E1BEC050B001546C6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 94181B1D1BEC050B001546C6 /* main.m */; }; 11 | 94181B211BEC050B001546C6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 94181B201BEC050B001546C6 /* AppDelegate.m */; }; 12 | 94181B241BEC050B001546C6 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 94181B231BEC050B001546C6 /* ViewController.m */; }; 13 | 94181B271BEC050B001546C6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 94181B251BEC050B001546C6 /* Main.storyboard */; }; 14 | 94181B291BEC050B001546C6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 94181B281BEC050B001546C6 /* Assets.xcassets */; }; 15 | 94181B2C1BEC050B001546C6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 94181B2A1BEC050B001546C6 /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 94181B191BEC050B001546C6 /* ImageToPDF.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageToPDF.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 94181B1D1BEC050B001546C6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 21 | 94181B1F1BEC050B001546C6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 22 | 94181B201BEC050B001546C6 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 23 | 94181B221BEC050B001546C6 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 24 | 94181B231BEC050B001546C6 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 25 | 94181B261BEC050B001546C6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 94181B281BEC050B001546C6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | 94181B2B1BEC050B001546C6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | 94181B2D1BEC050B001546C6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 94181B161BEC050B001546C6 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 94181B101BEC050B001546C6 = { 43 | isa = PBXGroup; 44 | children = ( 45 | 94181B1B1BEC050B001546C6 /* ImageToPDF */, 46 | 94181B1A1BEC050B001546C6 /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 94181B1A1BEC050B001546C6 /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 94181B191BEC050B001546C6 /* ImageToPDF.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 94181B1B1BEC050B001546C6 /* ImageToPDF */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 94181B1F1BEC050B001546C6 /* AppDelegate.h */, 62 | 94181B201BEC050B001546C6 /* AppDelegate.m */, 63 | 94181B221BEC050B001546C6 /* ViewController.h */, 64 | 94181B231BEC050B001546C6 /* ViewController.m */, 65 | 94181B251BEC050B001546C6 /* Main.storyboard */, 66 | 94181B281BEC050B001546C6 /* Assets.xcassets */, 67 | 94181B2A1BEC050B001546C6 /* LaunchScreen.storyboard */, 68 | 94181B2D1BEC050B001546C6 /* Info.plist */, 69 | 94181B1C1BEC050B001546C6 /* Supporting Files */, 70 | ); 71 | path = ImageToPDF; 72 | sourceTree = ""; 73 | }; 74 | 94181B1C1BEC050B001546C6 /* Supporting Files */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 94181B1D1BEC050B001546C6 /* main.m */, 78 | ); 79 | name = "Supporting Files"; 80 | sourceTree = ""; 81 | }; 82 | /* End PBXGroup section */ 83 | 84 | /* Begin PBXNativeTarget section */ 85 | 94181B181BEC050B001546C6 /* ImageToPDF */ = { 86 | isa = PBXNativeTarget; 87 | buildConfigurationList = 94181B301BEC050B001546C6 /* Build configuration list for PBXNativeTarget "ImageToPDF" */; 88 | buildPhases = ( 89 | 94181B151BEC050B001546C6 /* Sources */, 90 | 94181B161BEC050B001546C6 /* Frameworks */, 91 | 94181B171BEC050B001546C6 /* Resources */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = ImageToPDF; 98 | productName = ImageToPDF; 99 | productReference = 94181B191BEC050B001546C6 /* ImageToPDF.app */; 100 | productType = "com.apple.product-type.application"; 101 | }; 102 | /* End PBXNativeTarget section */ 103 | 104 | /* Begin PBXProject section */ 105 | 94181B111BEC050B001546C6 /* Project object */ = { 106 | isa = PBXProject; 107 | attributes = { 108 | LastUpgradeCheck = 1000; 109 | ORGANIZATIONNAME = Maxim; 110 | TargetAttributes = { 111 | 94181B181BEC050B001546C6 = { 112 | CreatedOnToolsVersion = 7.1; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = 94181B141BEC050B001546C6 /* Build configuration list for PBXProject "ImageToPDF" */; 117 | compatibilityVersion = "Xcode 3.2"; 118 | developmentRegion = English; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = 94181B101BEC050B001546C6; 125 | productRefGroup = 94181B1A1BEC050B001546C6 /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 94181B181BEC050B001546C6 /* ImageToPDF */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 94181B171BEC050B001546C6 /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 94181B2C1BEC050B001546C6 /* LaunchScreen.storyboard in Resources */, 140 | 94181B291BEC050B001546C6 /* Assets.xcassets in Resources */, 141 | 94181B271BEC050B001546C6 /* Main.storyboard in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | 94181B151BEC050B001546C6 /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 94181B241BEC050B001546C6 /* ViewController.m in Sources */, 153 | 94181B211BEC050B001546C6 /* AppDelegate.m in Sources */, 154 | 94181B1E1BEC050B001546C6 /* main.m in Sources */, 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXSourcesBuildPhase section */ 159 | 160 | /* Begin PBXVariantGroup section */ 161 | 94181B251BEC050B001546C6 /* Main.storyboard */ = { 162 | isa = PBXVariantGroup; 163 | children = ( 164 | 94181B261BEC050B001546C6 /* Base */, 165 | ); 166 | name = Main.storyboard; 167 | sourceTree = ""; 168 | }; 169 | 94181B2A1BEC050B001546C6 /* LaunchScreen.storyboard */ = { 170 | isa = PBXVariantGroup; 171 | children = ( 172 | 94181B2B1BEC050B001546C6 /* Base */, 173 | ); 174 | name = LaunchScreen.storyboard; 175 | sourceTree = ""; 176 | }; 177 | /* End PBXVariantGroup section */ 178 | 179 | /* Begin XCBuildConfiguration section */ 180 | 94181B2E1BEC050B001546C6 /* Debug */ = { 181 | isa = XCBuildConfiguration; 182 | buildSettings = { 183 | ALWAYS_SEARCH_USER_PATHS = NO; 184 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 185 | CLANG_CXX_LIBRARY = "libc++"; 186 | CLANG_ENABLE_MODULES = YES; 187 | CLANG_ENABLE_OBJC_ARC = YES; 188 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 189 | CLANG_WARN_BOOL_CONVERSION = YES; 190 | CLANG_WARN_COMMA = YES; 191 | CLANG_WARN_CONSTANT_CONVERSION = YES; 192 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 193 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 194 | CLANG_WARN_EMPTY_BODY = YES; 195 | CLANG_WARN_ENUM_CONVERSION = YES; 196 | CLANG_WARN_INFINITE_RECURSION = YES; 197 | CLANG_WARN_INT_CONVERSION = YES; 198 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 199 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 200 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 201 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 202 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 203 | CLANG_WARN_STRICT_PROTOTYPES = YES; 204 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 205 | CLANG_WARN_UNREACHABLE_CODE = YES; 206 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 207 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 208 | COPY_PHASE_STRIP = NO; 209 | DEBUG_INFORMATION_FORMAT = dwarf; 210 | ENABLE_STRICT_OBJC_MSGSEND = YES; 211 | ENABLE_TESTABILITY = YES; 212 | GCC_C_LANGUAGE_STANDARD = gnu99; 213 | GCC_DYNAMIC_NO_PIC = NO; 214 | GCC_NO_COMMON_BLOCKS = YES; 215 | GCC_OPTIMIZATION_LEVEL = 0; 216 | GCC_PREPROCESSOR_DEFINITIONS = ( 217 | "DEBUG=1", 218 | "$(inherited)", 219 | ); 220 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 221 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 222 | GCC_WARN_UNDECLARED_SELECTOR = YES; 223 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 224 | GCC_WARN_UNUSED_FUNCTION = YES; 225 | GCC_WARN_UNUSED_VARIABLE = YES; 226 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 227 | MTL_ENABLE_DEBUG_INFO = YES; 228 | ONLY_ACTIVE_ARCH = YES; 229 | SDKROOT = iphoneos; 230 | TARGETED_DEVICE_FAMILY = "1,2"; 231 | }; 232 | name = Debug; 233 | }; 234 | 94181B2F1BEC050B001546C6 /* Release */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 239 | CLANG_CXX_LIBRARY = "libc++"; 240 | CLANG_ENABLE_MODULES = YES; 241 | CLANG_ENABLE_OBJC_ARC = YES; 242 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 243 | CLANG_WARN_BOOL_CONVERSION = YES; 244 | CLANG_WARN_COMMA = YES; 245 | CLANG_WARN_CONSTANT_CONVERSION = YES; 246 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 247 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 248 | CLANG_WARN_EMPTY_BODY = YES; 249 | CLANG_WARN_ENUM_CONVERSION = YES; 250 | CLANG_WARN_INFINITE_RECURSION = YES; 251 | CLANG_WARN_INT_CONVERSION = YES; 252 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 253 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 254 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 255 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 256 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 257 | CLANG_WARN_STRICT_PROTOTYPES = YES; 258 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 259 | CLANG_WARN_UNREACHABLE_CODE = YES; 260 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 261 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 262 | COPY_PHASE_STRIP = NO; 263 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 264 | ENABLE_NS_ASSERTIONS = NO; 265 | ENABLE_STRICT_OBJC_MSGSEND = YES; 266 | GCC_C_LANGUAGE_STANDARD = gnu99; 267 | GCC_NO_COMMON_BLOCKS = YES; 268 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 269 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 270 | GCC_WARN_UNDECLARED_SELECTOR = YES; 271 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 272 | GCC_WARN_UNUSED_FUNCTION = YES; 273 | GCC_WARN_UNUSED_VARIABLE = YES; 274 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 275 | MTL_ENABLE_DEBUG_INFO = NO; 276 | SDKROOT = iphoneos; 277 | TARGETED_DEVICE_FAMILY = "1,2"; 278 | VALIDATE_PRODUCT = YES; 279 | }; 280 | name = Release; 281 | }; 282 | 94181B311BEC050B001546C6 /* Debug */ = { 283 | isa = XCBuildConfiguration; 284 | buildSettings = { 285 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 286 | INFOPLIST_FILE = ImageToPDF/Info.plist; 287 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 288 | PRODUCT_BUNDLE_IDENTIFIER = com.maximbilan.ImageToPDF; 289 | PRODUCT_NAME = "$(TARGET_NAME)"; 290 | }; 291 | name = Debug; 292 | }; 293 | 94181B321BEC050B001546C6 /* Release */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 297 | INFOPLIST_FILE = ImageToPDF/Info.plist; 298 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 299 | PRODUCT_BUNDLE_IDENTIFIER = com.maximbilan.ImageToPDF; 300 | PRODUCT_NAME = "$(TARGET_NAME)"; 301 | }; 302 | name = Release; 303 | }; 304 | /* End XCBuildConfiguration section */ 305 | 306 | /* Begin XCConfigurationList section */ 307 | 94181B141BEC050B001546C6 /* Build configuration list for PBXProject "ImageToPDF" */ = { 308 | isa = XCConfigurationList; 309 | buildConfigurations = ( 310 | 94181B2E1BEC050B001546C6 /* Debug */, 311 | 94181B2F1BEC050B001546C6 /* Release */, 312 | ); 313 | defaultConfigurationIsVisible = 0; 314 | defaultConfigurationName = Release; 315 | }; 316 | 94181B301BEC050B001546C6 /* Build configuration list for PBXNativeTarget "ImageToPDF" */ = { 317 | isa = XCConfigurationList; 318 | buildConfigurations = ( 319 | 94181B311BEC050B001546C6 /* Debug */, 320 | 94181B321BEC050B001546C6 /* Release */, 321 | ); 322 | defaultConfigurationIsVisible = 0; 323 | defaultConfigurationName = Release; 324 | }; 325 | /* End XCConfigurationList section */ 326 | }; 327 | rootObject = 94181B111BEC050B001546C6 /* Project object */; 328 | } 329 | -------------------------------------------------------------------------------- /ImageToPDF.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ImageToPDF.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ImageToPDF/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ImageToPDF 4 | // 5 | // Created by Maxim on 11/5/15. 6 | // Copyright © 2015 Maxim. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ImageToPDF/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ImageToPDF 4 | // 5 | // Created by Maxim on 11/5/15. 6 | // Copyright © 2015 Maxim. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /ImageToPDF/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /ImageToPDF/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ImageToPDF/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ImageToPDF/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ImageToPDF/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ImageToPDF 4 | // 5 | // Created by Maxim on 11/5/15. 6 | // Copyright © 2015 Maxim. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ImageToPDF/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ImageToPDF 4 | // 5 | // Created by Maxim on 11/5/15. 6 | // Copyright © 2015 Maxim. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad 18 | { 19 | [super viewDidLoad]; 20 | 21 | NSArray *documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES); 22 | NSString *documentDirectory = [documentDirectories objectAtIndex:0]; 23 | 24 | NSString *aFilename = @"test.pdf"; 25 | NSString *documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:aFilename]; 26 | 27 | NSLog(@"%@", documentDirectory); 28 | 29 | // Render 1000 UIImage objects to PDF file 30 | 31 | UIGraphicsBeginPDFContextToFile(documentDirectoryFilename, CGRectMake(0, 0, 1024, 1024), nil); 32 | 33 | for (NSInteger i = 0; i < 1000; ++i) { 34 | UIImage *image = [self imageFromColor:[self randomColor]]; 35 | 36 | @autoreleasepool { 37 | UIGraphicsBeginPDFPage(); 38 | [image drawAtPoint:CGPointZero]; 39 | } 40 | } 41 | 42 | UIGraphicsEndPDFContext(); 43 | 44 | aFilename = @"test_merge.pdf"; 45 | documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:aFilename]; 46 | 47 | // Render image to PDF file and merging 1000 pdf files to one PDF File 48 | 49 | NSMutableArray *pdfURLs = [NSMutableArray array]; 50 | for (NSInteger i = 0; i < 1000; ++i) { 51 | 52 | @autoreleasepool { 53 | NSString *pdfFile = [NSString stringWithFormat:@"%@_%@.%@", documentDirectoryFilename.stringByDeletingPathExtension, @(i), documentDirectoryFilename.pathExtension]; 54 | UIImage *imageToRender = [self imageFromColor:[self randomColor]]; 55 | UIGraphicsBeginPDFContextToFile(pdfFile, CGRectMake(0, 0, 1024, 1024), nil); 56 | UIGraphicsBeginPDFPage(); 57 | [imageToRender drawAtPoint:CGPointZero]; 58 | UIGraphicsEndPDFContext(); 59 | 60 | [pdfURLs addObject:[NSURL fileURLWithPath:pdfFile]]; 61 | } 62 | } 63 | 64 | [self combinePDFURLs:pdfURLs writeToURL:[NSURL fileURLWithPath:documentDirectoryFilename]]; 65 | 66 | for (NSURL *pdfUrl in pdfURLs) { 67 | [[NSFileManager defaultManager] removeItemAtURL:pdfUrl error:nil]; 68 | } 69 | } 70 | 71 | - (void)combinePDFURLs:(NSArray *)PDFURLs writeToURL:(NSURL *)URL 72 | { 73 | CGContextRef context = CGPDFContextCreateWithURL((__bridge CFURLRef)URL, NULL, NULL); 74 | 75 | for (NSURL *PDFURL in PDFURLs) { 76 | CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((__bridge CFURLRef)PDFURL); 77 | size_t numberOfPages = CGPDFDocumentGetNumberOfPages(document); 78 | 79 | for (size_t pageNumber = 1; pageNumber <= numberOfPages; ++pageNumber) { 80 | CGPDFPageRef page = CGPDFDocumentGetPage(document, pageNumber); 81 | CGRect mediaBox = CGPDFPageGetBoxRect(page, kCGPDFMediaBox); 82 | CGContextBeginPage(context, &mediaBox); 83 | CGContextDrawPDFPage(context, page); 84 | CGContextEndPage(context); 85 | } 86 | 87 | CGPDFDocumentRelease(document); 88 | } 89 | 90 | CGPDFContextClose(context); 91 | CGContextRelease(context); 92 | } 93 | 94 | - (UIImage *)imageFromColor:(UIColor *)color 95 | { 96 | CGRect rect = CGRectMake(0, 0, 1024, 1024); 97 | UIGraphicsBeginImageContext(rect.size); 98 | CGContextRef context = UIGraphicsGetCurrentContext(); 99 | CGContextSetFillColorWithColor(context, [color CGColor]); 100 | CGContextFillRect(context, rect); 101 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 102 | UIGraphicsEndImageContext(); 103 | return image; 104 | } 105 | 106 | - (UIColor *)randomColor 107 | { 108 | CGFloat hue = (arc4random() % 256 / 256.0); 109 | CGFloat saturation = (arc4random() % 128 / 256.0) + 0.5; 110 | CGFloat brightness = (arc4random() % 128 / 256.0) + 0.5; 111 | return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1]; 112 | } 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /ImageToPDF/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ImageToPDF 4 | // 5 | // Created by Maxim on 11/5/15. 6 | // Copyright © 2015 Maxim. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Maxim Bilan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS Render UIImage to PDF and merging PDF files 2 | 3 | ![alt tag](https://raw.github.com/maximbilan/iOS-UIImage-render-to-PDF/master/img/img1.png) 4 | 5 | Some code samples for working with PDF. Let’s try to generate 1000 images and render to PDF file. For this, we need a method for generating a random color and a method for creating UIImage from UIColor. 6 | 7 | A random color: 8 | 9 |
 10 | - (UIColor *)randomColor
 11 | {
 12 |     CGFloat hue = (arc4random() % 256 / 256.0);
 13 |     CGFloat saturation = (arc4random() % 128 / 256.0) + 0.5;
 14 |     CGFloat brightness = (arc4random() % 128 / 256.0 ) + 0.5;
 15 |     return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
 16 | }
 17 | 
18 | 19 | And UIImage from UIColor: 20 | 21 |
 22 | - (UIImage *)imageFromColor:(UIColor *)color
 23 | {
 24 |     CGRect rect = CGRectMake(0, 0, 1024, 1024);
 25 |     UIGraphicsBeginImageContext(rect.size);
 26 |     CGContextRef context = UIGraphicsGetCurrentContext();
 27 |     CGContextSetFillColorWithColor(context, [color CGColor]);
 28 |     CGContextFillRect(context, rect);
 29 |     UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
 30 |     UIGraphicsEndImageContext();
 31 |     return image;
 32 | }
 33 | 
34 | 35 | And now we can render random images to PDF file. 36 | 37 |
 38 | UIGraphicsBeginPDFContextToFile(filename, CGRectMake(0, 0, 1024, 1024), nil);
 39 | 
 40 | for (NSInteger i = 0; i < 1000; ++i) {
 41 |     UIImage *image = [self imageFromColor:[self randomColor]];
 42 | 
 43 |     @autoreleasepool {
 44 |         UIGraphicsBeginPDFPage();
 45 |         [image drawAtPoint:CGPointZero];
 46 |     }
 47 | }
 48 | 
 49 | UIGraphicsEndPDFContext();
 50 | 
51 | 52 | Attention! Necessarily use @autoreleasepool, otherwise, you will have memory leaks. 53 | 54 | Also, I would like to provide some sample for generating PDF files and merging these files. It’s also simple. 55 | 56 |
 57 | NSMutableArray *pdfURLs = [NSMutableArray array];
 58 | 
 59 | for (NSInteger i = 0; i < 1000; ++i) {
 60 |     NSString *pdfFile = [NSString stringWithFormat:@”%@_%@”, filename, @(i)];
 61 |     UIImage *imageToRender = [self imageFromColor:[self randomColor]];
 62 |   
 63 |     @autoreleasepool {
 64 |         UIGraphicsBeginPDFContextToFile(pdfFile, CGRectMake(0, 0, 1024, 1024), nil);
 65 |         UIGraphicsBeginPDFPage();
 66 |         [imageToRender drawAtPoint:CGPointZero];
 67 |         UIGraphicsEndPDFContext();
 68 |     }
 69 | 
 70 |     [pdfURLs addObject:[NSURL fileURLWithPath:pdfFile]];
 71 | }
 72 | 
 73 | [self combinePDFURLs:pdfURLs writeToURL:[NSURL fileURLWithPath:filename]];
 74 | 
 75 | for (NSURL *pdfUrl in pdfURLs) {
 76 |     [[NSFileManager defaultManager] removeItemAtURL:pdfUrl error:nil];
 77 | }
 78 | 
79 | 80 | And of course, implementation of combinePDFURLs method, see below: 81 | 82 |
 83 | - (void)combinePDFURLs:(NSArray *)PDFURLs writeToURL:(NSURL *)URL
 84 | {
 85 |     CGContextRef context = CGPDFContextCreateWithURL((__bridge CFURLRef)URL, NULL, NULL);
 86 | 
 87 |     for (NSURL *PDFURL in PDFURLs) {
 88 |         CGPDFDocumentRef document = CGPDFDocumentCreateWithURL((__bridge CFURLRef)PDFURL); 
 89 |         size_t numberOfPages = CGPDFDocumentGetNumberOfPages(document);
 90 | 
 91 |         for (size_t pageNumber = 1; pageNumber <= numberOfPages; ++pageNumber) {
 92 |             CGPDFPageRef page = CGPDFDocumentGetPage(document, pageNumber);
 93 |             CGRect mediaBox = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
 94 |             CGContextBeginPage(context, &mediaBox);
 95 |             CGContextDrawPDFPage(context, page);
 96 |             CGContextEndPage(context);
 97 |         }
 98 | 
 99 |         CGPDFDocumentRelease(document);
100 |     }
101 | 
102 |     CGPDFContextClose(context);
103 |     CGContextRelease(context);
104 | }
105 | 
106 | 107 | And the result: 108 | 109 | ![alt tag](https://raw.github.com/maximbilan/iOS-UIImage-render-to-PDF/master/img/img2.png) 110 | 111 | Happy coding! 112 | -------------------------------------------------------------------------------- /img/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maximbilan/iOS-UIImage-render-to-PDF/de9e0c5008d6b17d0cf6fdd9c50e1080997d65c7/img/img1.png -------------------------------------------------------------------------------- /img/img2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maximbilan/iOS-UIImage-render-to-PDF/de9e0c5008d6b17d0cf6fdd9c50e1080997d65c7/img/img2.png --------------------------------------------------------------------------------