├── .gitignore ├── LICENCE.md ├── README.md ├── SwiftPDFGenerator.swift ├── swift-pdf.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── swift-pdf ├── AppDelegate.swift ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json ├── Contents.json ├── logo.imageset │ ├── Contents.json │ └── cc.large.png └── test-images │ ├── Contents.json │ ├── test-image-1.imageset │ ├── Contents.json │ └── test-image-1.jpeg │ ├── test-image-2.imageset │ ├── Contents.json │ └── test-image-2.jpeg │ ├── test-image-3.imageset │ ├── Contents.json │ └── test-image-3.jpeg │ └── test-image-4.imageset │ ├── Contents.json │ └── test-image-4.jpeg ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── DisplayController.swift ├── Info.plist ├── PageOneView.swift ├── PageOneView.xib ├── PageTwoView.swift ├── PageTwoView.xib └── ViewController.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/screenshots 64 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 RobertAPhillips 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | The Library generates a PDF directly from interface builder with Auto-layouted views! Swift Version of [UIView_2_PDF](https://github.com/RobertAPhillips/UIView_2_PDF). 3 | 4 | ## Installation 5 | Download and drop ```SwiftPDFGenerator.swift``` in your project. 6 | 7 | ## Usage 8 | #### 1. Make a xib file. 9 | Your xib file should only consist of UILabels and/or UIImageViews and/or other UIView subviews. Use views that are 1 pixel high or wide to create lines. Set the tag of a UIView to 1 to have it draw filled or zero to draw as just a 1 pixel bordered box. 10 | 11 | #### 2. Load your xib like this 12 | ```swift 13 | let pageOneView = NSBundle.mainBundle().loadNibNamed("PageOneView", owner: self, options: nil).last as! PageOneView 14 | let pageTwoView = NSBundle.mainBundle().loadNibNamed("PageTwoView", owner: self, options: nil).last as! PageTwoView 15 | ``` 16 | 17 | #### 3. Then generate your PDF like this 18 | ```swift 19 | let filePath = SwiftPDFGenerator.generatePDFWithPages(pages) 20 | ``` 21 | 22 | See demo project for details. 23 | 24 | ## License 25 | swift-pdf is released under the MIT license. See 'LICENCE.md' for details. -------------------------------------------------------------------------------- /SwiftPDFGenerator.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2016 cr0ss 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | let SwiftPdfGeneratorCompression:Bool = false 29 | let SwiftPdfGeneratorCompressionValue:CGFloat = 0.5 30 | 31 | public class SwiftPDFGenerator { 32 | 33 | public static func generatePDFWithPages(pages:Array) -> String { 34 | let filePath:String = NSTemporaryDirectory().stringByAppendingPathComponent("report").stringByAppendingPathExtension("pdf")! 35 | UIGraphicsBeginPDFContextToFile(filePath, CGRect.zero, nil) 36 | let context = UIGraphicsGetCurrentContext() 37 | 38 | for page:UIView in pages { 39 | self.drawPageWithContext(page, context: context!) 40 | } 41 | UIGraphicsEndPDFContext() 42 | return filePath 43 | } 44 | 45 | private static func drawPageWithContext(page:UIView, context: CGContextRef) { 46 | UIGraphicsBeginPDFPageWithInfo(CGRect(x: 0.0, y: 0.0, width: page.bounds.size.width, height: page.bounds.size.height), nil) 47 | for subview:UIView in self.allSubViewsForPage(page) { 48 | if (subview.isKindOfClass(UIImageView)) { 49 | let imageView:UIImageView = subview as! UIImageView 50 | // Compress Image 51 | self.drawUIImageViewWithCompression(imageView, compression: SwiftPdfGeneratorCompression, compressionValue: SwiftPdfGeneratorCompressionValue) 52 | } else if (subview.isKindOfClass(UILabel)) { 53 | // get UILabel Styles 54 | let label:UILabel = subview as! UILabel 55 | let paragraphStyle:NSMutableParagraphStyle = NSParagraphStyle.defaultParagraphStyle().mutableCopy() as! NSMutableParagraphStyle 56 | paragraphStyle.lineBreakMode = label.lineBreakMode 57 | paragraphStyle.alignment = label.textAlignment 58 | 59 | NSString(string: label.text!).drawInRect(label.frame, withAttributes: [NSFontAttributeName:label.font, NSParagraphStyleAttributeName:paragraphStyle, NSForegroundColorAttributeName:label.textColor]) 60 | } else if (subview.isKindOfClass(UITextView)) { 61 | // Draw Border 62 | self.drawLinesUsingUIView(subview, thickness: 0.5, context: context, fillView: (subview.tag==1 ? true : false)) 63 | 64 | // Generate UILabel for UITextView.text 65 | let textView:UITextView = subview as! UITextView 66 | self.drawUITextView(textView) 67 | } else if (subview.isKindOfClass(UIView)) { 68 | self.drawLinesUsingUIView(subview, thickness: 0.5, context: context, fillView: (subview.tag==1 ? true : false)) 69 | } 70 | } 71 | } 72 | 73 | private static func drawUIImageViewWithCompression(imageView:UIImageView,compression:Bool, compressionValue:CGFloat=0.5) { 74 | if let image = imageView.image { 75 | if (imageView.contentMode == .ScaleAspectFit) { 76 | if (image.size.width > imageView.frame.size.width || image.size.height > imageView.frame.size.height) { 77 | if (image.size.width < image.size.height) { 78 | let maxHeight = imageView.frame.size.height 79 | let ratio = maxHeight / image.size.height 80 | let ratioWidth = image.size.width * ratio 81 | if (ratioWidth > imageView.frame.size.width) { 82 | let correctedMaxWidth = imageView.frame.size.width 83 | let correctedRatio = correctedMaxWidth / image.size.width 84 | let correctedRatioHeight = image.size.height * correctedRatio 85 | if compression { 86 | let compressedData:NSData = UIImageJPEGRepresentation(image,compressionValue)! 87 | let compressedImage:UIImage = UIImage(data: compressedData)! 88 | compressedImage.drawInRect(CGRect(x: imageView.frame.origin.x, y: imageView.frame.origin.y + (imageView.frame.height / 2) - (correctedRatioHeight / 2), width: correctedMaxWidth, height: correctedRatioHeight)) 89 | } else { 90 | image.drawInRect(CGRect(x: imageView.frame.origin.x, y: imageView.frame.origin.y + (imageView.frame.height / 2) - (correctedRatioHeight / 2), width: correctedMaxWidth, height: correctedRatioHeight)) 91 | } 92 | } else { 93 | if compression { 94 | let compressedData:NSData = UIImageJPEGRepresentation(image,compressionValue)! 95 | let compressedImage:UIImage = UIImage(data: compressedData)! 96 | compressedImage.drawInRect(CGRect(x: imageView.frame.origin.x + (imageView.frame.width / 2) - (ratioWidth / 2), y: imageView.frame.origin.y, width: ratioWidth, height: maxHeight)) 97 | } else { 98 | image.drawInRect(CGRect(x: imageView.frame.origin.x + (imageView.frame.width / 2) - (ratioWidth / 2), y: imageView.frame.origin.y, width: ratioWidth, height: maxHeight)) 99 | } 100 | } 101 | } else { 102 | let maxWidth = imageView.frame.size.width 103 | let ratio = maxWidth / image.size.width 104 | let ratioHeight = image.size.height * ratio 105 | if (ratioHeight > imageView.frame.size.height) { 106 | let correctedMaxHeight = imageView.frame.size.height 107 | let correctedRatio = correctedMaxHeight / image.size.height 108 | let correctedRatioWidth = image.size.width * correctedRatio 109 | 110 | if compression { 111 | let compressedData:NSData = UIImageJPEGRepresentation(image,compressionValue)! 112 | let compressedImage:UIImage = UIImage(data: compressedData)! 113 | compressedImage.drawInRect(CGRect(x: imageView.frame.origin.x + (imageView.frame.width / 2) - (correctedRatioWidth / 2), y: imageView.frame.origin.y, width: correctedRatioWidth, height: correctedMaxHeight)) 114 | } else { 115 | image.drawInRect(CGRect(x: imageView.frame.origin.x + (imageView.frame.width / 2) - (correctedRatioWidth / 2), y: imageView.frame.origin.y, width: correctedRatioWidth, height: correctedMaxHeight)) 116 | } 117 | } else { 118 | if compression { 119 | let compressedData:NSData = UIImageJPEGRepresentation(image,compressionValue)! 120 | let compressedImage:UIImage = UIImage(data: compressedData)! 121 | compressedImage.drawInRect(CGRect(x: imageView.frame.origin.x, y: imageView.frame.origin.y + (imageView.frame.height / 2) - (ratioHeight / 2), width: maxWidth, height: ratioHeight)) 122 | } else { 123 | image.drawInRect(CGRect(x: imageView.frame.origin.x, y: imageView.frame.origin.y + (imageView.frame.height / 2) - (ratioHeight / 2), width: maxWidth, height: ratioHeight)) 124 | } 125 | } 126 | } 127 | } else { 128 | image.drawInRect(imageView.frame) 129 | } 130 | } else { 131 | image.drawInRect(imageView.frame) 132 | } 133 | } 134 | } 135 | 136 | private static func drawUITextView(textView:UITextView) { 137 | textView.selectable = true 138 | let textViewFrame:CGRect = CGRect(x: textView.frame.origin.x + 2, y: textView.frame.origin.y + 2, width: textView.frame.size.width - 4, height: textView.frame.size.height - 4) 139 | // Get UITextView.text Styles 140 | let paragraphStyle:NSMutableParagraphStyle = NSParagraphStyle.defaultParagraphStyle().mutableCopy() as! NSMutableParagraphStyle 141 | paragraphStyle.lineBreakMode = .ByWordWrapping 142 | paragraphStyle.alignment = textView.textAlignment 143 | 144 | if let font = textView.font, let textColor = textView.textColor { 145 | NSString(string: textView.text).drawInRect(textViewFrame, withAttributes: [NSFontAttributeName:font, NSParagraphStyleAttributeName:paragraphStyle, NSForegroundColorAttributeName:textColor]) 146 | } else { 147 | NSString(string: textView.text).drawInRect(textViewFrame, withAttributes: [NSFontAttributeName:UIFont.systemFontOfSize(10), NSParagraphStyleAttributeName:paragraphStyle, NSForegroundColorAttributeName:UIColor(red: 70.0/255.0, green: 74.0/255.0, blue: 72.0/255.0, alpha: 1.0)]) 148 | } 149 | } 150 | 151 | private static func drawLinesUsingUIView(view:UIView, thickness:CGFloat, context:CGContextRef, fillView:Bool) { 152 | CGContextSaveGState(context) 153 | CGContextSetStrokeColorWithColor(context, view.backgroundColor?.CGColor) 154 | CGContextSetFillColorWithColor(context, view.backgroundColor?.CGColor) 155 | CGContextSetLineWidth(context, thickness) 156 | 157 | if (view.frame.size.width > 1 && view.frame.size.height == 1) { 158 | CGContextMoveToPoint(context, view.frame.origin.x-0.5, view.frame.origin.y) 159 | CGContextAddLineToPoint(context, view.frame.origin.x+view.frame.size.width-0.5, view.frame.origin.y) 160 | CGContextStrokePath(context) 161 | } else if (view.frame.size.width == 1 && view.frame.size.height > 1) { 162 | CGContextMoveToPoint(context, view.frame.origin.x, view.frame.origin.y-0.5) 163 | CGContextAddLineToPoint(context, view.frame.origin.x, view.frame.origin.y+view.frame.size.height+0.5) 164 | CGContextStrokePath(context) 165 | } else if (view.frame.size.width > 1 && view.frame.size.height > 1) { 166 | if (fillView) { 167 | CGContextSetFillColorWithColor(context, view.backgroundColor!.CGColor) 168 | CGContextFillRect(context, view.frame) 169 | } 170 | CGContextStrokeRect(context, view.frame) 171 | } else { 172 | // print("0x0 view") 173 | } 174 | CGContextRestoreGState(context) 175 | } 176 | 177 | private static func allSubViewsForPage(page:UIView) -> Array { 178 | var returnArray:Array = [] 179 | returnArray.append(page) 180 | for subview:UIView in page.subviews { 181 | if subview.hidden == false { 182 | if (subview.isKindOfClass(UILabel)) { 183 | let label:UILabel = subview as! UILabel 184 | label.sizeToFit() 185 | label.layoutIfNeeded() 186 | } 187 | let origin:CGPoint = (subview.superview?.convertPoint(subview.frame.origin, toView: subview.superview?.superview))! 188 | subview.frame = CGRect(x: origin.x, y: origin.y, width: subview.frame.size.width, height: subview.frame.size.height) 189 | returnArray.appendContentsOf(self.allSubViewsForPage(subview)) 190 | } 191 | } 192 | return returnArray 193 | } 194 | } 195 | 196 | extension String { 197 | func stringByAppendingPathComponent(path: String) -> String { 198 | let nsSt = self as NSString 199 | return nsSt.stringByAppendingPathComponent(path) 200 | } 201 | 202 | func stringByAppendingPathExtension(ext: String) -> String? { 203 | let nsSt = self as NSString 204 | return nsSt.stringByAppendingPathExtension(ext) 205 | } 206 | } -------------------------------------------------------------------------------- /swift-pdf.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 60B7F5C81C9CDD1300F52B4E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60B7F5C71C9CDD1300F52B4E /* AppDelegate.swift */; }; 11 | 60B7F5CA1C9CDD1300F52B4E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60B7F5C91C9CDD1300F52B4E /* ViewController.swift */; }; 12 | 60B7F5CD1C9CDD1300F52B4E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 60B7F5CB1C9CDD1300F52B4E /* Main.storyboard */; }; 13 | 60B7F5CF1C9CDD1300F52B4E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 60B7F5CE1C9CDD1300F52B4E /* Assets.xcassets */; }; 14 | 60B7F5D21C9CDD1300F52B4E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 60B7F5D01C9CDD1300F52B4E /* LaunchScreen.storyboard */; }; 15 | 60B7F5DE1C9CDEA400F52B4E /* PageOneView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60B7F5DB1C9CDEA400F52B4E /* PageOneView.swift */; }; 16 | 60B7F5DF1C9CDEA400F52B4E /* PageOneView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 60B7F5DC1C9CDEA400F52B4E /* PageOneView.xib */; }; 17 | 60B7F5E61C9CE1FB00F52B4E /* DisplayController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60B7F5E51C9CE1FB00F52B4E /* DisplayController.swift */; }; 18 | 60C29AA71C9F559D00131394 /* PageTwoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C29AA61C9F559D00131394 /* PageTwoView.swift */; }; 19 | 60C29AA91C9F587E00131394 /* PageTwoView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 60C29AA81C9F587E00131394 /* PageTwoView.xib */; }; 20 | 60D5D5BE1CAABB600098A113 /* SwiftPDFGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60D5D5BD1CAABB600098A113 /* SwiftPDFGenerator.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXCopyFilesBuildPhase section */ 24 | 60C29AA11C9F52DC00131394 /* Embed Frameworks */ = { 25 | isa = PBXCopyFilesBuildPhase; 26 | buildActionMask = 2147483647; 27 | dstPath = ""; 28 | dstSubfolderSpec = 10; 29 | files = ( 30 | ); 31 | name = "Embed Frameworks"; 32 | runOnlyForDeploymentPostprocessing = 0; 33 | }; 34 | /* End PBXCopyFilesBuildPhase section */ 35 | 36 | /* Begin PBXFileReference section */ 37 | 60B7F5C41C9CDD1300F52B4E /* swift-pdf.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "swift-pdf.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 60B7F5C71C9CDD1300F52B4E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 39 | 60B7F5C91C9CDD1300F52B4E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 40 | 60B7F5CC1C9CDD1300F52B4E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | 60B7F5CE1C9CDD1300F52B4E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 42 | 60B7F5D11C9CDD1300F52B4E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 43 | 60B7F5D31C9CDD1300F52B4E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | 60B7F5DB1C9CDEA400F52B4E /* PageOneView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageOneView.swift; sourceTree = ""; }; 45 | 60B7F5DC1C9CDEA400F52B4E /* PageOneView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PageOneView.xib; sourceTree = ""; }; 46 | 60B7F5E51C9CE1FB00F52B4E /* DisplayController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisplayController.swift; sourceTree = ""; }; 47 | 60C29AA61C9F559D00131394 /* PageTwoView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageTwoView.swift; sourceTree = ""; }; 48 | 60C29AA81C9F587E00131394 /* PageTwoView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PageTwoView.xib; sourceTree = ""; }; 49 | 60D5D5BD1CAABB600098A113 /* SwiftPDFGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftPDFGenerator.swift; sourceTree = SOURCE_ROOT; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 60B7F5C11C9CDD1300F52B4E /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | /* End PBXFrameworksBuildPhase section */ 61 | 62 | /* Begin PBXGroup section */ 63 | 60B7F5BB1C9CDD1300F52B4E = { 64 | isa = PBXGroup; 65 | children = ( 66 | 60B7F5C61C9CDD1300F52B4E /* swift-pdf */, 67 | 60B7F5C51C9CDD1300F52B4E /* Products */, 68 | ); 69 | sourceTree = ""; 70 | }; 71 | 60B7F5C51C9CDD1300F52B4E /* Products */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 60B7F5C41C9CDD1300F52B4E /* swift-pdf.app */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | 60B7F5C61C9CDD1300F52B4E /* swift-pdf */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 60D5D5BD1CAABB600098A113 /* SwiftPDFGenerator.swift */, 83 | 60B7F5C71C9CDD1300F52B4E /* AppDelegate.swift */, 84 | 60B7F5C91C9CDD1300F52B4E /* ViewController.swift */, 85 | 60B7F5E51C9CE1FB00F52B4E /* DisplayController.swift */, 86 | 60B7F5E41C9CDEC700F52B4E /* swift-pdf */, 87 | 60B7F5E21C9CDEB500F52B4E /* Supporting Files */, 88 | ); 89 | path = "swift-pdf"; 90 | sourceTree = ""; 91 | }; 92 | 60B7F5E11C9CDEAE00F52B4E /* Storyboard */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 60B7F5CB1C9CDD1300F52B4E /* Main.storyboard */, 96 | 60B7F5D01C9CDD1300F52B4E /* LaunchScreen.storyboard */, 97 | ); 98 | name = Storyboard; 99 | sourceTree = ""; 100 | }; 101 | 60B7F5E21C9CDEB500F52B4E /* Supporting Files */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 60B7F5E11C9CDEAE00F52B4E /* Storyboard */, 105 | 60B7F5CE1C9CDD1300F52B4E /* Assets.xcassets */, 106 | 60B7F5D31C9CDD1300F52B4E /* Info.plist */, 107 | ); 108 | name = "Supporting Files"; 109 | sourceTree = ""; 110 | }; 111 | 60B7F5E31C9CDEBE00F52B4E /* Pages */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | 60B7F5DC1C9CDEA400F52B4E /* PageOneView.xib */, 115 | 60B7F5DB1C9CDEA400F52B4E /* PageOneView.swift */, 116 | 60C29AA81C9F587E00131394 /* PageTwoView.xib */, 117 | 60C29AA61C9F559D00131394 /* PageTwoView.swift */, 118 | ); 119 | name = Pages; 120 | sourceTree = ""; 121 | }; 122 | 60B7F5E41C9CDEC700F52B4E /* swift-pdf */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 60B7F5E31C9CDEBE00F52B4E /* Pages */, 126 | ); 127 | name = "swift-pdf"; 128 | sourceTree = ""; 129 | }; 130 | /* End PBXGroup section */ 131 | 132 | /* Begin PBXNativeTarget section */ 133 | 60B7F5C31C9CDD1300F52B4E /* swift-pdf */ = { 134 | isa = PBXNativeTarget; 135 | buildConfigurationList = 60B7F5D61C9CDD1300F52B4E /* Build configuration list for PBXNativeTarget "swift-pdf" */; 136 | buildPhases = ( 137 | 60B7F5C01C9CDD1300F52B4E /* Sources */, 138 | 60B7F5C11C9CDD1300F52B4E /* Frameworks */, 139 | 60B7F5C21C9CDD1300F52B4E /* Resources */, 140 | 60C29AA11C9F52DC00131394 /* Embed Frameworks */, 141 | ); 142 | buildRules = ( 143 | ); 144 | dependencies = ( 145 | ); 146 | name = "swift-pdf"; 147 | productName = "swift-pdf"; 148 | productReference = 60B7F5C41C9CDD1300F52B4E /* swift-pdf.app */; 149 | productType = "com.apple.product-type.application"; 150 | }; 151 | /* End PBXNativeTarget section */ 152 | 153 | /* Begin PBXProject section */ 154 | 60B7F5BC1C9CDD1300F52B4E /* Project object */ = { 155 | isa = PBXProject; 156 | attributes = { 157 | LastSwiftUpdateCheck = 0720; 158 | LastUpgradeCheck = 0720; 159 | ORGANIZATIONNAME = kayos; 160 | TargetAttributes = { 161 | 60B7F5C31C9CDD1300F52B4E = { 162 | CreatedOnToolsVersion = 7.2.1; 163 | }; 164 | }; 165 | }; 166 | buildConfigurationList = 60B7F5BF1C9CDD1300F52B4E /* Build configuration list for PBXProject "swift-pdf" */; 167 | compatibilityVersion = "Xcode 3.2"; 168 | developmentRegion = English; 169 | hasScannedForEncodings = 0; 170 | knownRegions = ( 171 | en, 172 | Base, 173 | ); 174 | mainGroup = 60B7F5BB1C9CDD1300F52B4E; 175 | productRefGroup = 60B7F5C51C9CDD1300F52B4E /* Products */; 176 | projectDirPath = ""; 177 | projectRoot = ""; 178 | targets = ( 179 | 60B7F5C31C9CDD1300F52B4E /* swift-pdf */, 180 | ); 181 | }; 182 | /* End PBXProject section */ 183 | 184 | /* Begin PBXResourcesBuildPhase section */ 185 | 60B7F5C21C9CDD1300F52B4E /* Resources */ = { 186 | isa = PBXResourcesBuildPhase; 187 | buildActionMask = 2147483647; 188 | files = ( 189 | 60B7F5D21C9CDD1300F52B4E /* LaunchScreen.storyboard in Resources */, 190 | 60C29AA91C9F587E00131394 /* PageTwoView.xib in Resources */, 191 | 60B7F5CF1C9CDD1300F52B4E /* Assets.xcassets in Resources */, 192 | 60B7F5DF1C9CDEA400F52B4E /* PageOneView.xib in Resources */, 193 | 60B7F5CD1C9CDD1300F52B4E /* Main.storyboard in Resources */, 194 | ); 195 | runOnlyForDeploymentPostprocessing = 0; 196 | }; 197 | /* End PBXResourcesBuildPhase section */ 198 | 199 | /* Begin PBXSourcesBuildPhase section */ 200 | 60B7F5C01C9CDD1300F52B4E /* Sources */ = { 201 | isa = PBXSourcesBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | 60B7F5CA1C9CDD1300F52B4E /* ViewController.swift in Sources */, 205 | 60B7F5E61C9CE1FB00F52B4E /* DisplayController.swift in Sources */, 206 | 60D5D5BE1CAABB600098A113 /* SwiftPDFGenerator.swift in Sources */, 207 | 60B7F5C81C9CDD1300F52B4E /* AppDelegate.swift in Sources */, 208 | 60C29AA71C9F559D00131394 /* PageTwoView.swift in Sources */, 209 | 60B7F5DE1C9CDEA400F52B4E /* PageOneView.swift in Sources */, 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | /* End PBXSourcesBuildPhase section */ 214 | 215 | /* Begin PBXVariantGroup section */ 216 | 60B7F5CB1C9CDD1300F52B4E /* Main.storyboard */ = { 217 | isa = PBXVariantGroup; 218 | children = ( 219 | 60B7F5CC1C9CDD1300F52B4E /* Base */, 220 | ); 221 | name = Main.storyboard; 222 | sourceTree = ""; 223 | }; 224 | 60B7F5D01C9CDD1300F52B4E /* LaunchScreen.storyboard */ = { 225 | isa = PBXVariantGroup; 226 | children = ( 227 | 60B7F5D11C9CDD1300F52B4E /* Base */, 228 | ); 229 | name = LaunchScreen.storyboard; 230 | sourceTree = ""; 231 | }; 232 | /* End PBXVariantGroup section */ 233 | 234 | /* Begin XCBuildConfiguration section */ 235 | 60B7F5D41C9CDD1300F52B4E /* Debug */ = { 236 | isa = XCBuildConfiguration; 237 | buildSettings = { 238 | ALWAYS_SEARCH_USER_PATHS = NO; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_WARN_BOOL_CONVERSION = YES; 244 | CLANG_WARN_CONSTANT_CONVERSION = YES; 245 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 246 | CLANG_WARN_EMPTY_BODY = YES; 247 | CLANG_WARN_ENUM_CONVERSION = YES; 248 | CLANG_WARN_INT_CONVERSION = YES; 249 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 250 | CLANG_WARN_UNREACHABLE_CODE = YES; 251 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 252 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 253 | COPY_PHASE_STRIP = NO; 254 | DEBUG_INFORMATION_FORMAT = dwarf; 255 | ENABLE_STRICT_OBJC_MSGSEND = YES; 256 | ENABLE_TESTABILITY = YES; 257 | GCC_C_LANGUAGE_STANDARD = gnu99; 258 | GCC_DYNAMIC_NO_PIC = NO; 259 | GCC_NO_COMMON_BLOCKS = YES; 260 | GCC_OPTIMIZATION_LEVEL = 0; 261 | GCC_PREPROCESSOR_DEFINITIONS = ( 262 | "DEBUG=1", 263 | "$(inherited)", 264 | ); 265 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 266 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 267 | GCC_WARN_UNDECLARED_SELECTOR = YES; 268 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 269 | GCC_WARN_UNUSED_FUNCTION = YES; 270 | GCC_WARN_UNUSED_VARIABLE = YES; 271 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 272 | MTL_ENABLE_DEBUG_INFO = YES; 273 | ONLY_ACTIVE_ARCH = YES; 274 | SDKROOT = iphoneos; 275 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 276 | TARGETED_DEVICE_FAMILY = "1,2"; 277 | }; 278 | name = Debug; 279 | }; 280 | 60B7F5D51C9CDD1300F52B4E /* Release */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | ALWAYS_SEARCH_USER_PATHS = NO; 284 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 285 | CLANG_CXX_LIBRARY = "libc++"; 286 | CLANG_ENABLE_MODULES = YES; 287 | CLANG_ENABLE_OBJC_ARC = YES; 288 | CLANG_WARN_BOOL_CONVERSION = YES; 289 | CLANG_WARN_CONSTANT_CONVERSION = YES; 290 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 291 | CLANG_WARN_EMPTY_BODY = YES; 292 | CLANG_WARN_ENUM_CONVERSION = YES; 293 | CLANG_WARN_INT_CONVERSION = YES; 294 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 295 | CLANG_WARN_UNREACHABLE_CODE = YES; 296 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 297 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 298 | COPY_PHASE_STRIP = NO; 299 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 300 | ENABLE_NS_ASSERTIONS = NO; 301 | ENABLE_STRICT_OBJC_MSGSEND = YES; 302 | GCC_C_LANGUAGE_STANDARD = gnu99; 303 | GCC_NO_COMMON_BLOCKS = YES; 304 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 305 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 306 | GCC_WARN_UNDECLARED_SELECTOR = YES; 307 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 308 | GCC_WARN_UNUSED_FUNCTION = YES; 309 | GCC_WARN_UNUSED_VARIABLE = YES; 310 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 311 | MTL_ENABLE_DEBUG_INFO = NO; 312 | SDKROOT = iphoneos; 313 | TARGETED_DEVICE_FAMILY = "1,2"; 314 | VALIDATE_PRODUCT = YES; 315 | }; 316 | name = Release; 317 | }; 318 | 60B7F5D71C9CDD1300F52B4E /* Debug */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 322 | INFOPLIST_FILE = "swift-pdf/Info.plist"; 323 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 324 | PRODUCT_BUNDLE_IDENTIFIER = "kayos.swift-pdf"; 325 | PRODUCT_NAME = "$(TARGET_NAME)"; 326 | }; 327 | name = Debug; 328 | }; 329 | 60B7F5D81C9CDD1300F52B4E /* Release */ = { 330 | isa = XCBuildConfiguration; 331 | buildSettings = { 332 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 333 | INFOPLIST_FILE = "swift-pdf/Info.plist"; 334 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 335 | PRODUCT_BUNDLE_IDENTIFIER = "kayos.swift-pdf"; 336 | PRODUCT_NAME = "$(TARGET_NAME)"; 337 | }; 338 | name = Release; 339 | }; 340 | /* End XCBuildConfiguration section */ 341 | 342 | /* Begin XCConfigurationList section */ 343 | 60B7F5BF1C9CDD1300F52B4E /* Build configuration list for PBXProject "swift-pdf" */ = { 344 | isa = XCConfigurationList; 345 | buildConfigurations = ( 346 | 60B7F5D41C9CDD1300F52B4E /* Debug */, 347 | 60B7F5D51C9CDD1300F52B4E /* Release */, 348 | ); 349 | defaultConfigurationIsVisible = 0; 350 | defaultConfigurationName = Release; 351 | }; 352 | 60B7F5D61C9CDD1300F52B4E /* Build configuration list for PBXNativeTarget "swift-pdf" */ = { 353 | isa = XCConfigurationList; 354 | buildConfigurations = ( 355 | 60B7F5D71C9CDD1300F52B4E /* Debug */, 356 | 60B7F5D81C9CDD1300F52B4E /* Release */, 357 | ); 358 | defaultConfigurationIsVisible = 0; 359 | defaultConfigurationName = Release; 360 | }; 361 | /* End XCConfigurationList section */ 362 | }; 363 | rootObject = 60B7F5BC1C9CDD1300F52B4E /* Project object */; 364 | } 365 | -------------------------------------------------------------------------------- /swift-pdf.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /swift-pdf/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2016 cr0ss 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import UIKit 26 | 27 | @UIApplicationMain 28 | class AppDelegate: UIResponder, UIApplicationDelegate { 29 | 30 | var window: UIWindow? 31 | 32 | 33 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 34 | // Override point for customization after application launch. 35 | return true 36 | } 37 | 38 | func applicationWillResignActive(application: UIApplication) { 39 | // 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. 40 | // 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. 41 | } 42 | 43 | func applicationDidEnterBackground(application: UIApplication) { 44 | // 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. 45 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 46 | } 47 | 48 | func applicationWillEnterForeground(application: UIApplication) { 49 | // 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. 50 | } 51 | 52 | func applicationDidBecomeActive(application: UIApplication) { 53 | // 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. 54 | } 55 | 56 | func applicationWillTerminate(application: UIApplication) { 57 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 58 | } 59 | 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /swift-pdf/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 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/logo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "cc.large.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/logo.imageset/cc.large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kayoslab/SwiftPDFGenerator/a1e2ea76dede725ac223e76d5c8003d9cb4ece01/swift-pdf/Assets.xcassets/logo.imageset/cc.large.png -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/test-images/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/test-images/test-image-1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "test-image-1.jpeg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/test-images/test-image-1.imageset/test-image-1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kayoslab/SwiftPDFGenerator/a1e2ea76dede725ac223e76d5c8003d9cb4ece01/swift-pdf/Assets.xcassets/test-images/test-image-1.imageset/test-image-1.jpeg -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/test-images/test-image-2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "test-image-2.jpeg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/test-images/test-image-2.imageset/test-image-2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kayoslab/SwiftPDFGenerator/a1e2ea76dede725ac223e76d5c8003d9cb4ece01/swift-pdf/Assets.xcassets/test-images/test-image-2.imageset/test-image-2.jpeg -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/test-images/test-image-3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "test-image-3.jpeg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/test-images/test-image-3.imageset/test-image-3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kayoslab/SwiftPDFGenerator/a1e2ea76dede725ac223e76d5c8003d9cb4ece01/swift-pdf/Assets.xcassets/test-images/test-image-3.imageset/test-image-3.jpeg -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/test-images/test-image-4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "test-image-4.jpeg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /swift-pdf/Assets.xcassets/test-images/test-image-4.imageset/test-image-4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kayoslab/SwiftPDFGenerator/a1e2ea76dede725ac223e76d5c8003d9cb4ece01/swift-pdf/Assets.xcassets/test-images/test-image-4.imageset/test-image-4.jpeg -------------------------------------------------------------------------------- /swift-pdf/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 | -------------------------------------------------------------------------------- /swift-pdf/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 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /swift-pdf/DisplayController.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2016 cr0ss 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import UIKit 26 | 27 | class DisplayController: UIViewController { 28 | @IBOutlet var contentView: UIWebView! 29 | var url:NSURL? 30 | 31 | // MARK: - Controller Implementation 32 | func configureView() { 33 | // Update the user interface for the detail item. 34 | if let url = self.url { 35 | if let contentView = self.contentView { 36 | print(url) 37 | contentView.loadRequest(NSURLRequest(URL: url)) 38 | } 39 | } 40 | } 41 | 42 | override func viewDidLoad() { 43 | super.viewDidLoad() 44 | let backButton = UIBarButtonItem(barButtonSystemItem: .Cancel, target: self, action: #selector(DisplayController.cancelButtonTouched)) 45 | let shareButton = UIBarButtonItem(barButtonSystemItem: .Action, target: self, action: #selector(DisplayController.shareButtonTouched)) 46 | self.navigationItem.leftBarButtonItem = backButton 47 | self.navigationItem.rightBarButtonItem = shareButton 48 | self.configureView() 49 | } 50 | 51 | func cancelButtonTouched() { 52 | self.dismissViewControllerAnimated(true, completion: {}); 53 | } 54 | 55 | func shareButtonTouched() { 56 | let objectsToShare: Array = [NSData(contentsOfURL: url!)!] 57 | let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil) 58 | self.presentViewController(activityVC, animated: true, completion: nil) 59 | } 60 | } -------------------------------------------------------------------------------- /swift-pdf/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 | -------------------------------------------------------------------------------- /swift-pdf/PageOneView.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2016 cr0ss 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | class PageOneView: UIView { 29 | @IBOutlet internal weak var dateLabel: UILabel! 30 | @IBOutlet internal weak var reportLabel: UILabel! 31 | 32 | @IBOutlet internal weak var tenantCompanyLabel: UILabel! 33 | @IBOutlet internal weak var tenantNameLabel: UILabel! 34 | @IBOutlet internal weak var tenantStreetLabel: UILabel! 35 | @IBOutlet internal weak var tenantPlzAndCityLabel: UILabel! 36 | @IBOutlet internal weak var tenantCountryLabel: UILabel! 37 | 38 | internal func setupViewContent() { 39 | let dateFormatter = NSDateFormatter() 40 | dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle 41 | dateFormatter.timeStyle = NSDateFormatterStyle.NoStyle 42 | if let dateLabel = self.dateLabel { 43 | dateLabel.text = dateFormatter.stringFromDate(NSDate()) 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /swift-pdf/PageOneView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 30 | 39 | 48 | 57 | 66 | 75 | 84 | 93 | 99 | 105 | 111 | 117 | 123 | 129 | 135 | 141 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 192 | 193 | 194 | 195 | Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 196 | 197 | Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. 198 | 199 | Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. 200 | 201 | Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. 202 | 203 | Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. 204 | 205 | At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | -------------------------------------------------------------------------------- /swift-pdf/PageTwoView.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2016 cr0ss 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | class PageTwoView: UIView { 29 | @IBOutlet internal weak var dateLabel: UILabel! 30 | @IBOutlet internal weak var reportLabel: UILabel! 31 | 32 | @IBOutlet internal weak var tenantCompanyLabel: UILabel! 33 | @IBOutlet internal weak var tenantNameLabel: UILabel! 34 | @IBOutlet internal weak var tenantStreetLabel: UILabel! 35 | @IBOutlet internal weak var tenantPlzAndCityLabel: UILabel! 36 | @IBOutlet internal weak var tenantCountryLabel: UILabel! 37 | 38 | internal func setupViewContent() { 39 | let dateFormatter = NSDateFormatter() 40 | dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle 41 | dateFormatter.timeStyle = NSDateFormatterStyle.NoStyle 42 | if let dateLabel = self.dateLabel { 43 | dateLabel.text = dateFormatter.stringFromDate(NSDate()) 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /swift-pdf/PageTwoView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 30 | 39 | 48 | 57 | 66 | 75 | 84 | 93 | 99 | 105 | 111 | 117 | 123 | 129 | 135 | 141 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | -------------------------------------------------------------------------------- /swift-pdf/ViewController.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2016 cr0ss 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import UIKit 26 | 27 | class ViewController: UIViewController { 28 | 29 | override func viewDidLoad() { 30 | super.viewDidLoad() 31 | // Do any additional setup after loading the view, typically from a nib. 32 | } 33 | 34 | override func didReceiveMemoryWarning() { 35 | super.didReceiveMemoryWarning() 36 | // Dispose of any resources that can be recreated. 37 | } 38 | 39 | @IBAction func generateButtonTouchUpInside(sender: UIButton) { 40 | var pages:Array = [] 41 | 42 | // Load Views with NibName 43 | let pageOneView = NSBundle.mainBundle().loadNibNamed("PageOneView", owner: self, options: nil).last as! PageOneView 44 | let pageTwoView = NSBundle.mainBundle().loadNibNamed("PageTwoView", owner: self, options: nil).last as! PageTwoView 45 | // Fill Views With Data 46 | pageOneView.setupViewContent() 47 | pageTwoView.setupViewContent() 48 | 49 | // Generate PDF from pages Array 50 | pages.appendContentsOf([pageOneView, pageTwoView]) 51 | let tempFilePath = SwiftPDFGenerator.generatePDFWithPages(pages) 52 | 53 | // present PDF 54 | let newEventController = self.storyboard!.instantiateViewControllerWithIdentifier("PDFNavigationController") as! UINavigationController 55 | newEventController.modalPresentationStyle = .PageSheet 56 | let pdfLoc = NSURL(fileURLWithPath: tempFilePath) 57 | (newEventController.childViewControllers[0] as! DisplayController).url = pdfLoc 58 | self.presentViewController(newEventController, animated: true, completion: nil) 59 | } 60 | } 61 | 62 | --------------------------------------------------------------------------------