[
  {
    "path": ".gitignore",
    "content": "build\nxcuserdata\n*.mode*\n*pbxuser\n*.perspectivev3\nproject.xcworkspace\n*.xcuserstate\n*tmproj\n~*\n.DS_Store\n*.orig\n"
  },
  {
    "path": "Print2PDF/AddItemViewController.swift",
    "content": "//\n//  AddItemViewController.swift\n//  Print2PDF\n//\n//  Created by Gabriel Theodoropoulos on 14/06/16.\n//  Copyright © 2016 Appcoda. All rights reserved.\n//\n\nimport UIKit\n\nclass AddItemViewController: UIViewController, UITextFieldDelegate {\n\n    @IBOutlet weak var txtItemDescription: UITextField!\n    \n    @IBOutlet weak var txtPrice: UITextField!\n    \n    \n    var currentTextfield: UITextField!\n    \n    var saveCompletionHandler: ((_ itemDescription: String, _ price: String) -> Void)!\n    \n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \n        // Set self as the delegate of the textfields.\n        txtItemDescription.delegate = self\n        txtPrice.delegate = self\n        \n        // Add a tap gesture recognizer to the view to dismiss the keyboard.\n        let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(AddItemViewController.dismissKeyboard))\n        view.addGestureRecognizer(tapGestureRecognizer)\n    }\n\n    override func didReceiveMemoryWarning() {\n        super.didReceiveMemoryWarning()\n        // Dispose of any resources that can be recreated.\n    }\n    \n\n    /*\n    // MARK: - Navigation\n\n    // In a storyboard-based application, you will often want to do a little preparation before navigation\n    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {\n        // Get the new view controller using segue.destinationViewController.\n        // Pass the selected object to the new view controller.\n    }\n    */\n\n    \n    // MARK: Custom Methods\n    \n    func dismissKeyboard() {\n        if currentTextfield != nil {\n            currentTextfield.resignFirstResponder()\n            currentTextfield = nil\n        }\n    }\n    \n    \n    func presentAddItemViewControllerInViewController(originatingViewController: UIViewController, saveItemCompletionHandler: @escaping (_ itemDescription: String, _ price: String) -> Void) {\n        saveCompletionHandler = saveItemCompletionHandler\n        originatingViewController.navigationController?.pushViewController(self, animated: true)\n    }\n    \n    \n    // MARK: IBAction Methods\n    \n    @IBAction func saveItem(_ sender: AnyObject) {\n        if (txtItemDescription.text?.characters.count)! > 0 &&\n            (txtPrice.text?.characters.count)! > 0 {\n            \n            if saveCompletionHandler != nil {\n                // Call the save completion handler to pass the item description and the price back to the CreatorViewController object.\n                \n                saveCompletionHandler(_ : txtItemDescription.text!, _: txtPrice.text!)\n                \n                // Pop the view controller.\n                _ = navigationController?.popViewController(animated: true)\n            }\n        }\n    }\n    \n    \n    \n    // MARK: UITextFieldDelegate Methods\n    \n    func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {\n        currentTextfield = textField\n        return true\n    }\n    \n    \n    func textFieldShouldReturn(_ textField: UITextField) -> Bool {\n        if textField == txtItemDescription {\n            textField.resignFirstResponder()\n            txtPrice.becomeFirstResponder()\n        }\n        \n        return true\n    }\n    \n}\n"
  },
  {
    "path": "Print2PDF/AppDelegate.swift",
    "content": "//\n//  AppDelegate.swift\n//  Print2PDF\n//\n//  Created by Gabriel Theodoropoulos on 14/06/16.\n//  Copyright © 2016 Appcoda. All rights reserved.\n//\n\nimport UIKit\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n\n    var window: UIWindow?\n\n    let currencyCode = \"eur\"\n    \n\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {\n        // Override point for customization after application launch.\n        return true\n    }\n\n    \n    // MARK: Custom Methods\n    \n    class func getAppDelegate() -> AppDelegate {\n        return UIApplication.shared.delegate as! AppDelegate\n    }\n    \n    \n    func getStringValueFormattedAsCurrency(value: String) -> String {\n        let numberFormatter = NumberFormatter()\n        numberFormatter.numberStyle = NumberFormatter.Style.currency\n        numberFormatter.currencyCode = currencyCode\n        numberFormatter.maximumFractionDigits = 2\n        \n        let formattedValue = numberFormatter.string(from: NumberFormatter().number(from: value)!)\n        return formattedValue!\n    }\n    \n    \n    func getDocDir() -> String {\n        return NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]\n    }\n    \n}\n\n"
  },
  {
    "path": "Print2PDF/Assets.xcassets/AppIcon.appiconset/Contents.json",
    "content": "{\n  \"images\" : [\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"60x60\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"60x60\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"76x76\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"76x76\",\n      \"scale\" : \"2x\"\n    }\n  ],\n  \"info\" : {\n    \"version\" : 1,\n    \"author\" : \"xcode\"\n  }\n}"
  },
  {
    "path": "Print2PDF/Base.lproj/LaunchScreen.storyboard",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3.0\" toolsVersion=\"8150\" systemVersion=\"15A204g\" targetRuntime=\"iOS.CocoaTouch\" propertyAccessControl=\"none\" useAutolayout=\"YES\" launchScreen=\"YES\" useTraitCollections=\"YES\" initialViewController=\"01J-lp-oVM\">\n    <dependencies>\n        <plugIn identifier=\"com.apple.InterfaceBuilder.IBCocoaTouchPlugin\" version=\"8122\"/>\n    </dependencies>\n    <scenes>\n        <!--View Controller-->\n        <scene sceneID=\"EHf-IW-A2E\">\n            <objects>\n                <viewController id=\"01J-lp-oVM\" sceneMemberID=\"viewController\">\n                    <layoutGuides>\n                        <viewControllerLayoutGuide type=\"top\" id=\"Llm-lL-Icb\"/>\n                        <viewControllerLayoutGuide type=\"bottom\" id=\"xb3-aO-Qok\"/>\n                    </layoutGuides>\n                    <view key=\"view\" contentMode=\"scaleToFill\" id=\"Ze5-6b-2t3\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"600\" height=\"600\"/>\n                        <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                        <animations/>\n                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"calibratedWhite\"/>\n                    </view>\n                </viewController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"iYj-Kq-Ea1\" userLabel=\"First Responder\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"53\" y=\"375\"/>\n        </scene>\n    </scenes>\n</document>\n"
  },
  {
    "path": "Print2PDF/Base.lproj/Main.storyboard",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3.0\" toolsVersion=\"10116\" systemVersion=\"15A284\" targetRuntime=\"iOS.CocoaTouch\" propertyAccessControl=\"none\" useAutolayout=\"YES\" useTraitCollections=\"YES\" initialViewController=\"orp-cW-drb\">\n    <dependencies>\n        <deployment identifier=\"iOS\"/>\n        <plugIn identifier=\"com.apple.InterfaceBuilder.IBCocoaTouchPlugin\" version=\"10085\"/>\n        <capability name=\"Constraints to layout margins\" minToolsVersion=\"6.0\"/>\n    </dependencies>\n    <scenes>\n        <!--Invoice List View Controller-->\n        <scene sceneID=\"tne-QT-ifu\">\n            <objects>\n                <viewController automaticallyAdjustsScrollViewInsets=\"NO\" id=\"BYZ-38-t0r\" customClass=\"InvoiceListViewController\" customModule=\"Print2PDF\" customModuleProvider=\"target\" sceneMemberID=\"viewController\">\n                    <layoutGuides>\n                        <viewControllerLayoutGuide type=\"top\" id=\"y3c-jy-aDJ\"/>\n                        <viewControllerLayoutGuide type=\"bottom\" id=\"wfy-db-euE\"/>\n                    </layoutGuides>\n                    <view key=\"view\" contentMode=\"scaleToFill\" id=\"8bC-Xf-vdC\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"600\" height=\"600\"/>\n                        <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                        <subviews>\n                            <tableView clipsSubviews=\"YES\" contentMode=\"scaleToFill\" alwaysBounceVertical=\"YES\" dataMode=\"prototypes\" style=\"plain\" separatorStyle=\"default\" rowHeight=\"44\" sectionHeaderHeight=\"28\" sectionFooterHeight=\"28\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"yo6-cb-KTQ\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"64\" width=\"600\" height=\"536\"/>\n                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"calibratedWhite\"/>\n                                <prototypes>\n                                    <tableViewCell clipsSubviews=\"YES\" contentMode=\"scaleToFill\" selectionStyle=\"default\" accessoryType=\"disclosureIndicator\" indentationWidth=\"10\" reuseIdentifier=\"invoiceCell\" id=\"xTZ-Rv-Ddy\">\n                                        <rect key=\"frame\" x=\"0.0\" y=\"28\" width=\"600\" height=\"44\"/>\n                                        <autoresizingMask key=\"autoresizingMask\"/>\n                                        <tableViewCellContentView key=\"contentView\" opaque=\"NO\" clipsSubviews=\"YES\" multipleTouchEnabled=\"YES\" contentMode=\"center\" tableViewCell=\"xTZ-Rv-Ddy\" id=\"PXz-uD-OPb\">\n                                            <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"567\" height=\"43\"/>\n                                            <autoresizingMask key=\"autoresizingMask\"/>\n                                        </tableViewCellContentView>\n                                    </tableViewCell>\n                                </prototypes>\n                            </tableView>\n                        </subviews>\n                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"calibratedWhite\"/>\n                        <constraints>\n                            <constraint firstItem=\"wfy-db-euE\" firstAttribute=\"top\" secondItem=\"yo6-cb-KTQ\" secondAttribute=\"bottom\" id=\"Chv-4Y-uTT\"/>\n                            <constraint firstItem=\"yo6-cb-KTQ\" firstAttribute=\"top\" secondItem=\"y3c-jy-aDJ\" secondAttribute=\"bottom\" id=\"TWC-RL-ia1\"/>\n                            <constraint firstItem=\"yo6-cb-KTQ\" firstAttribute=\"leading\" secondItem=\"8bC-Xf-vdC\" secondAttribute=\"leadingMargin\" constant=\"-20\" id=\"eSB-Lj-bSC\"/>\n                            <constraint firstAttribute=\"trailingMargin\" secondItem=\"yo6-cb-KTQ\" secondAttribute=\"trailing\" constant=\"-20\" id=\"qdg-Ta-Ix6\"/>\n                        </constraints>\n                    </view>\n                    <navigationItem key=\"navigationItem\" id=\"82B-eR-Fgg\">\n                        <barButtonItem key=\"rightBarButtonItem\" systemItem=\"add\" id=\"HlV-Wt-A6c\">\n                            <connections>\n                                <action selector=\"createInvoice:\" destination=\"BYZ-38-t0r\" id=\"DIn-ql-M0R\"/>\n                            </connections>\n                        </barButtonItem>\n                    </navigationItem>\n                    <connections>\n                        <outlet property=\"tblInvoices\" destination=\"yo6-cb-KTQ\" id=\"VT1-iO-yUa\"/>\n                        <segue destination=\"WAP-F9-I3Z\" kind=\"show\" identifier=\"idSeguePresentCreator\" id=\"xnN-U9-ldL\"/>\n                        <segue destination=\"N0b-RX-mJe\" kind=\"show\" identifier=\"idSeguePresentPreview\" id=\"8Ur-XB-KzF\"/>\n                    </connections>\n                </viewController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"dkx-z0-nzr\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"620\" y=\"165\"/>\n        </scene>\n        <!--Creator View Controller-->\n        <scene sceneID=\"IyW-Sz-TpM\">\n            <objects>\n                <viewController storyboardIdentifier=\"idCreateInvoice\" automaticallyAdjustsScrollViewInsets=\"NO\" id=\"WAP-F9-I3Z\" customClass=\"CreatorViewController\" customModule=\"Print2PDF\" customModuleProvider=\"target\" sceneMemberID=\"viewController\">\n                    <layoutGuides>\n                        <viewControllerLayoutGuide type=\"top\" id=\"mbN-b8-fyX\"/>\n                        <viewControllerLayoutGuide type=\"bottom\" id=\"eoC-r6-fOw\"/>\n                    </layoutGuides>\n                    <view key=\"view\" contentMode=\"scaleToFill\" id=\"0rY-IY-DVi\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"600\" height=\"600\"/>\n                        <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                        <subviews>\n                            <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"Recipient Info:\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"AED-lz-kBC\">\n                                <rect key=\"frame\" x=\"20\" y=\"72\" width=\"189\" height=\"21\"/>\n                                <constraints>\n                                    <constraint firstAttribute=\"width\" constant=\"189\" id=\"qkx-kb-WQK\"/>\n                                    <constraint firstAttribute=\"height\" constant=\"21\" id=\"uuX-L5-4aD\"/>\n                                </constraints>\n                                <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                <color key=\"textColor\" white=\"0.66666666666666663\" alpha=\"1\" colorSpace=\"calibratedWhite\"/>\n                                <nil key=\"highlightedColor\"/>\n                            </label>\n                            <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"Invoice Items:\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Yhh-ef-Rot\">\n                                <rect key=\"frame\" x=\"20\" y=\"234\" width=\"189\" height=\"21\"/>\n                                <constraints>\n                                    <constraint firstAttribute=\"height\" constant=\"21\" id=\"IEk-je-NhF\"/>\n                                    <constraint firstAttribute=\"width\" constant=\"189\" id=\"zUn-5G-6VI\"/>\n                                </constraints>\n                                <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                <color key=\"textColor\" white=\"0.66666666666666663\" alpha=\"1\" colorSpace=\"calibratedWhite\"/>\n                                <nil key=\"highlightedColor\"/>\n                            </label>\n                            <toolbar opaque=\"NO\" clearsContextBeforeDrawing=\"NO\" contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"NTc-VZ-xvo\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"556\" width=\"600\" height=\"44\"/>\n                                <constraints>\n                                    <constraint firstAttribute=\"height\" constant=\"44\" id=\"pVd-Rv-hTz\"/>\n                                </constraints>\n                                <items>\n                                    <barButtonItem title=\"Total:\" id=\"mVA-Is-NsK\"/>\n                                    <barButtonItem style=\"plain\" systemItem=\"flexibleSpace\" id=\"bk5-X4-3Bb\"/>\n                                    <barButtonItem systemItem=\"add\" id=\"gzY-DJ-XQ1\">\n                                        <connections>\n                                            <action selector=\"addItem:\" destination=\"WAP-F9-I3Z\" id=\"v5Q-br-cSq\"/>\n                                        </connections>\n                                    </barButtonItem>\n                                </items>\n                            </toolbar>\n                            <tableView clipsSubviews=\"YES\" contentMode=\"scaleToFill\" alwaysBounceVertical=\"YES\" dataMode=\"prototypes\" style=\"plain\" separatorStyle=\"default\" rowHeight=\"44\" sectionHeaderHeight=\"28\" sectionFooterHeight=\"28\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Yd7-HA-YJG\">\n                                <rect key=\"frame\" x=\"20\" y=\"255\" width=\"560\" height=\"290\"/>\n                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"calibratedWhite\"/>\n                                <prototypes>\n                                    <tableViewCell clipsSubviews=\"YES\" contentMode=\"scaleToFill\" selectionStyle=\"none\" indentationWidth=\"10\" reuseIdentifier=\"itemCell\" textLabel=\"bkx-jD-jC3\" detailTextLabel=\"JDk-6K-4TP\" style=\"IBUITableViewCellStyleValue1\" id=\"0Gm-5s-XdY\">\n                                        <rect key=\"frame\" x=\"0.0\" y=\"28\" width=\"560\" height=\"44\"/>\n                                        <autoresizingMask key=\"autoresizingMask\"/>\n                                        <tableViewCellContentView key=\"contentView\" opaque=\"NO\" clipsSubviews=\"YES\" multipleTouchEnabled=\"YES\" contentMode=\"center\" tableViewCell=\"0Gm-5s-XdY\" id=\"AS7-KW-yDD\">\n                                            <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"560\" height=\"43\"/>\n                                            <autoresizingMask key=\"autoresizingMask\"/>\n                                            <subviews>\n                                                <label opaque=\"NO\" multipleTouchEnabled=\"YES\" contentMode=\"left\" text=\"Title\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" id=\"bkx-jD-jC3\">\n                                                    <rect key=\"frame\" x=\"15\" y=\"12\" width=\"32\" height=\"20\"/>\n                                                    <autoresizingMask key=\"autoresizingMask\" flexibleMaxX=\"YES\" flexibleMaxY=\"YES\"/>\n                                                    <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"16\"/>\n                                                    <color key=\"textColor\" red=\"0.0\" green=\"0.0\" blue=\"0.0\" alpha=\"1\" colorSpace=\"calibratedRGB\"/>\n                                                    <nil key=\"highlightedColor\"/>\n                                                </label>\n                                                <label opaque=\"NO\" multipleTouchEnabled=\"YES\" contentMode=\"left\" text=\"Detail\" textAlignment=\"right\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" id=\"JDk-6K-4TP\">\n                                                    <rect key=\"frame\" x=\"503\" y=\"12\" width=\"42\" height=\"20\"/>\n                                                    <autoresizingMask key=\"autoresizingMask\" flexibleMaxX=\"YES\" flexibleMaxY=\"YES\"/>\n                                                    <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"16\"/>\n                                                    <color key=\"textColor\" red=\"0.55686274509803924\" green=\"0.55686274509803924\" blue=\"0.57647058823529407\" alpha=\"1\" colorSpace=\"calibratedRGB\"/>\n                                                    <nil key=\"highlightedColor\"/>\n                                                </label>\n                                            </subviews>\n                                        </tableViewCellContentView>\n                                    </tableViewCell>\n                                </prototypes>\n                            </tableView>\n                            <textView clipsSubviews=\"YES\" multipleTouchEnabled=\"YES\" contentMode=\"scaleToFill\" textAlignment=\"natural\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"9su-63-jEX\">\n                                <rect key=\"frame\" x=\"20\" y=\"98\" width=\"560\" height=\"128\"/>\n                                <color key=\"backgroundColor\" red=\"0.90196079019999997\" green=\"0.90196079019999997\" blue=\"0.90196079019999997\" alpha=\"1\" colorSpace=\"calibratedRGB\"/>\n                                <constraints>\n                                    <constraint firstAttribute=\"height\" constant=\"128\" id=\"4pq-Bv-hmX\"/>\n                                </constraints>\n                                <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"14\"/>\n                                <textInputTraits key=\"textInputTraits\" autocapitalizationType=\"sentences\"/>\n                            </textView>\n                        </subviews>\n                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"calibratedWhite\"/>\n                        <constraints>\n                            <constraint firstItem=\"AED-lz-kBC\" firstAttribute=\"top\" secondItem=\"mbN-b8-fyX\" secondAttribute=\"bottom\" constant=\"8\" id=\"EdG-mS-EpR\"/>\n                            <constraint firstItem=\"Yhh-ef-Rot\" firstAttribute=\"top\" secondItem=\"9su-63-jEX\" secondAttribute=\"bottom\" constant=\"8\" id=\"G4D-xs-fEX\"/>\n                            <constraint firstItem=\"NTc-VZ-xvo\" firstAttribute=\"leading\" secondItem=\"0rY-IY-DVi\" secondAttribute=\"leadingMargin\" constant=\"-20\" id=\"Gmt-KX-orE\"/>\n                            <constraint firstItem=\"NTc-VZ-xvo\" firstAttribute=\"top\" secondItem=\"Yd7-HA-YJG\" secondAttribute=\"bottom\" constant=\"11\" id=\"LUb-vb-dHt\"/>\n                            <constraint firstItem=\"9su-63-jEX\" firstAttribute=\"leading\" secondItem=\"0rY-IY-DVi\" secondAttribute=\"leadingMargin\" id=\"OSO-kp-dze\"/>\n                            <constraint firstItem=\"AED-lz-kBC\" firstAttribute=\"leading\" secondItem=\"0rY-IY-DVi\" secondAttribute=\"leadingMargin\" id=\"TjL-y6-B5Z\"/>\n                            <constraint firstItem=\"Yd7-HA-YJG\" firstAttribute=\"leading\" secondItem=\"0rY-IY-DVi\" secondAttribute=\"leadingMargin\" id=\"Xbe-4B-Qsx\"/>\n                            <constraint firstItem=\"eoC-r6-fOw\" firstAttribute=\"top\" secondItem=\"NTc-VZ-xvo\" secondAttribute=\"bottom\" id=\"XoA-1k-g2T\"/>\n                            <constraint firstAttribute=\"trailingMargin\" secondItem=\"NTc-VZ-xvo\" secondAttribute=\"trailing\" constant=\"-20\" id=\"eqb-FJ-agb\"/>\n                            <constraint firstItem=\"Yhh-ef-Rot\" firstAttribute=\"leading\" secondItem=\"0rY-IY-DVi\" secondAttribute=\"leadingMargin\" id=\"inn-Qp-M5x\"/>\n                            <constraint firstItem=\"Yd7-HA-YJG\" firstAttribute=\"trailing\" secondItem=\"0rY-IY-DVi\" secondAttribute=\"trailingMargin\" id=\"jX8-2D-1IG\"/>\n                            <constraint firstAttribute=\"trailingMargin\" secondItem=\"9su-63-jEX\" secondAttribute=\"trailing\" id=\"jpa-41-Frm\"/>\n                            <constraint firstItem=\"Yd7-HA-YJG\" firstAttribute=\"top\" secondItem=\"Yhh-ef-Rot\" secondAttribute=\"bottom\" id=\"q7N-hQ-R41\"/>\n                            <constraint firstItem=\"9su-63-jEX\" firstAttribute=\"top\" secondItem=\"mbN-b8-fyX\" secondAttribute=\"bottom\" constant=\"34\" id=\"rtb-aJ-17o\"/>\n                        </constraints>\n                    </view>\n                    <navigationItem key=\"navigationItem\" id=\"MmZ-zm-mew\">\n                        <barButtonItem key=\"rightBarButtonItem\" systemItem=\"save\" id=\"8M2-R1-ngz\">\n                            <connections>\n                                <action selector=\"saveInvoice:\" destination=\"WAP-F9-I3Z\" id=\"q8j-YV-y1H\"/>\n                            </connections>\n                        </barButtonItem>\n                    </navigationItem>\n                    <connections>\n                        <outlet property=\"bbiTotal\" destination=\"mVA-Is-NsK\" id=\"1tc-u8-vOG\"/>\n                        <outlet property=\"tblInvoiceItems\" destination=\"Yd7-HA-YJG\" id=\"Yq2-vp-ipx\"/>\n                        <outlet property=\"tvRecipientInfo\" destination=\"9su-63-jEX\" id=\"7L7-OV-Y9x\"/>\n                        <segue destination=\"Kxm-nt-nUb\" kind=\"show\" identifier=\"idSeguePresentAddItem\" id=\"IjY-w6-3a1\"/>\n                    </connections>\n                </viewController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"x7m-3a-TtX\" userLabel=\"First Responder\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"1439\" y=\"-293\"/>\n        </scene>\n        <!--Preview View Controller-->\n        <scene sceneID=\"MbO-WJ-6zz\">\n            <objects>\n                <viewController id=\"N0b-RX-mJe\" customClass=\"PreviewViewController\" customModule=\"Print2PDF\" customModuleProvider=\"target\" sceneMemberID=\"viewController\">\n                    <layoutGuides>\n                        <viewControllerLayoutGuide type=\"top\" id=\"XdU-Mo-vKd\"/>\n                        <viewControllerLayoutGuide type=\"bottom\" id=\"LeA-95-WR8\"/>\n                    </layoutGuides>\n                    <view key=\"view\" contentMode=\"scaleToFill\" id=\"1dj-n8-uBZ\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"600\" height=\"600\"/>\n                        <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                        <subviews>\n                            <webView contentMode=\"scaleToFill\" scalesPageToFit=\"YES\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"3Ca-ak-dqG\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"600\" height=\"600\"/>\n                                <color key=\"backgroundColor\" red=\"0.36078431370000003\" green=\"0.38823529410000002\" blue=\"0.4039215686\" alpha=\"1\" colorSpace=\"deviceRGB\"/>\n                            </webView>\n                        </subviews>\n                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"calibratedWhite\"/>\n                        <constraints>\n                            <constraint firstItem=\"LeA-95-WR8\" firstAttribute=\"top\" secondItem=\"3Ca-ak-dqG\" secondAttribute=\"bottom\" id=\"RQI-Qq-5cJ\"/>\n                            <constraint firstItem=\"3Ca-ak-dqG\" firstAttribute=\"leading\" secondItem=\"1dj-n8-uBZ\" secondAttribute=\"leadingMargin\" constant=\"-20\" id=\"Soc-qi-4Dh\"/>\n                            <constraint firstItem=\"3Ca-ak-dqG\" firstAttribute=\"top\" secondItem=\"XdU-Mo-vKd\" secondAttribute=\"bottom\" constant=\"-64\" id=\"fYh-CT-2PF\"/>\n                            <constraint firstAttribute=\"trailingMargin\" secondItem=\"3Ca-ak-dqG\" secondAttribute=\"trailing\" constant=\"-20\" id=\"lJf-33-QOg\"/>\n                        </constraints>\n                    </view>\n                    <navigationItem key=\"navigationItem\" id=\"Iqt-u4-Sd2\">\n                        <barButtonItem key=\"rightBarButtonItem\" title=\"PDF\" id=\"UXX-tS-GQe\">\n                            <connections>\n                                <action selector=\"exportToPDF:\" destination=\"N0b-RX-mJe\" id=\"2MI-xz-fXV\"/>\n                            </connections>\n                        </barButtonItem>\n                    </navigationItem>\n                    <connections>\n                        <outlet property=\"webPreview\" destination=\"3Ca-ak-dqG\" id=\"WbG-xe-HXB\"/>\n                    </connections>\n                </viewController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"fbz-k9-D9q\" userLabel=\"First Responder\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"1439\" y=\"411\"/>\n        </scene>\n        <!--Add Item View Controller-->\n        <scene sceneID=\"YxM-Hf-f0r\">\n            <objects>\n                <viewController storyboardIdentifier=\"idAddItem\" id=\"Kxm-nt-nUb\" customClass=\"AddItemViewController\" customModule=\"Print2PDF\" customModuleProvider=\"target\" sceneMemberID=\"viewController\">\n                    <layoutGuides>\n                        <viewControllerLayoutGuide type=\"top\" id=\"G9n-Rd-WgX\"/>\n                        <viewControllerLayoutGuide type=\"bottom\" id=\"Cab-7Y-OL1\"/>\n                    </layoutGuides>\n                    <view key=\"view\" contentMode=\"scaleToFill\" id=\"dcj-PZ-K5I\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"600\" height=\"600\"/>\n                        <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                        <subviews>\n                            <textField opaque=\"NO\" clipsSubviews=\"YES\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"left\" contentVerticalAlignment=\"center\" borderStyle=\"roundedRect\" placeholder=\"Price...\" textAlignment=\"center\" minimumFontSize=\"17\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"OIa-FX-7nh\">\n                                <rect key=\"frame\" x=\"20\" y=\"158\" width=\"560\" height=\"30\"/>\n                                <constraints>\n                                    <constraint firstAttribute=\"height\" constant=\"30\" id=\"it0-Vv-sop\"/>\n                                </constraints>\n                                <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"14\"/>\n                                <textInputTraits key=\"textInputTraits\" keyboardType=\"numberPad\" returnKeyType=\"done\"/>\n                            </textField>\n                            <textField opaque=\"NO\" clipsSubviews=\"YES\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"left\" contentVerticalAlignment=\"center\" borderStyle=\"roundedRect\" placeholder=\"Item or Service description...\" textAlignment=\"center\" minimumFontSize=\"17\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"kmr-Th-a0P\">\n                                <rect key=\"frame\" x=\"20\" y=\"98\" width=\"560\" height=\"30\"/>\n                                <constraints>\n                                    <constraint firstAttribute=\"height\" constant=\"30\" id=\"hXv-Vw-lAM\"/>\n                                </constraints>\n                                <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"14\"/>\n                                <textInputTraits key=\"textInputTraits\" returnKeyType=\"next\"/>\n                            </textField>\n                        </subviews>\n                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"calibratedWhite\"/>\n                        <constraints>\n                            <constraint firstItem=\"kmr-Th-a0P\" firstAttribute=\"leading\" secondItem=\"dcj-PZ-K5I\" secondAttribute=\"leadingMargin\" id=\"5kS-2j-EBW\"/>\n                            <constraint firstItem=\"OIa-FX-7nh\" firstAttribute=\"trailing\" secondItem=\"dcj-PZ-K5I\" secondAttribute=\"trailingMargin\" id=\"Hjk-b8-6tv\"/>\n                            <constraint firstItem=\"OIa-FX-7nh\" firstAttribute=\"leading\" secondItem=\"dcj-PZ-K5I\" secondAttribute=\"leadingMargin\" id=\"Ofs-Yv-sTx\"/>\n                            <constraint firstItem=\"OIa-FX-7nh\" firstAttribute=\"top\" secondItem=\"kmr-Th-a0P\" secondAttribute=\"bottom\" constant=\"30\" id=\"QoG-Px-0JA\"/>\n                            <constraint firstItem=\"kmr-Th-a0P\" firstAttribute=\"trailing\" secondItem=\"dcj-PZ-K5I\" secondAttribute=\"trailingMargin\" id=\"WLO-1S-JuL\"/>\n                            <constraint firstItem=\"kmr-Th-a0P\" firstAttribute=\"top\" secondItem=\"G9n-Rd-WgX\" secondAttribute=\"bottom\" constant=\"34\" id=\"oxN-SZ-0wF\"/>\n                        </constraints>\n                    </view>\n                    <navigationItem key=\"navigationItem\" id=\"ydz-QL-08J\">\n                        <barButtonItem key=\"rightBarButtonItem\" systemItem=\"save\" id=\"6ea-Yj-Hz9\">\n                            <connections>\n                                <action selector=\"saveItem:\" destination=\"Kxm-nt-nUb\" id=\"s18-0O-tEj\"/>\n                            </connections>\n                        </barButtonItem>\n                    </navigationItem>\n                    <connections>\n                        <outlet property=\"txtItemDescription\" destination=\"kmr-Th-a0P\" id=\"QYD-XO-Nke\"/>\n                        <outlet property=\"txtPrice\" destination=\"OIa-FX-7nh\" id=\"wV2-Yc-oIa\"/>\n                    </connections>\n                </viewController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"qNC-hl-ylg\" userLabel=\"First Responder\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"2256\" y=\"-293\"/>\n        </scene>\n        <!--Navigation Controller-->\n        <scene sceneID=\"k84-tD-0vU\">\n            <objects>\n                <navigationController automaticallyAdjustsScrollViewInsets=\"NO\" id=\"orp-cW-drb\" sceneMemberID=\"viewController\">\n                    <toolbarItems/>\n                    <navigationBar key=\"navigationBar\" contentMode=\"scaleToFill\" id=\"e8d-at-r7d\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"320\" height=\"44\"/>\n                        <autoresizingMask key=\"autoresizingMask\"/>\n                    </navigationBar>\n                    <nil name=\"viewControllers\"/>\n                    <connections>\n                        <segue destination=\"BYZ-38-t0r\" kind=\"relationship\" relationship=\"rootViewController\" id=\"lwo-sJ-nIw\"/>\n                    </connections>\n                </navigationController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"TJw-oV-eya\" userLabel=\"First Responder\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"-180\" y=\"165\"/>\n        </scene>\n    </scenes>\n</document>\n"
  },
  {
    "path": "Print2PDF/CreatorViewController.swift",
    "content": "//\n//  CreatorViewController.swift\n//  Print2PDF\n//\n//  Created by Gabriel Theodoropoulos on 14/06/16.\n//  Copyright © 2016 Appcoda. All rights reserved.\n//\n\nimport UIKit\n\nclass CreatorViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {\n\n    @IBOutlet weak var tblInvoiceItems: UITableView!\n    \n    @IBOutlet weak var bbiTotal: UIBarButtonItem!\n    \n    @IBOutlet weak var tvRecipientInfo: UITextView!\n    \n    \n    var invoiceNumber: String!\n    \n    var items: [[String: String]]!\n    \n    var totalAmount = \"0\"\n    \n    var saveCompletionHandler: ((_ invoiceNumber: String, _ recipientInfo: String, _ totalAmount: String, _ items: [[String: String]]) -> Void)!\n    \n    var firstAppeared = true\n    \n    var nextNumberAsString: String!\n    \n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \n        // Set self as the delegate and the datasource of the tableview.\n        tblInvoiceItems.delegate = self\n        tblInvoiceItems.dataSource = self\n        \n        \n        // Add a tap gesture recognizer to the view to dismiss the keyboard.\n        let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(AddItemViewController.dismissKeyboard))\n        view.addGestureRecognizer(tapGestureRecognizer)\n    }\n\n    \n    override func viewWillAppear(_ animated: Bool) {\n        super.viewWillAppear(animated)\n        \n        if firstAppeared {\n            determineInvoiceNumber()\n            displayTotalAmount()\n            firstAppeared = false\n        }\n    }\n    \n    \n    override func didReceiveMemoryWarning() {\n        super.didReceiveMemoryWarning()\n        // Dispose of any resources that can be recreated.\n    }\n    \n\n    /*\n    // MARK: - Navigation\n\n    // In a storyboard-based application, you will often want to do a little preparation before navigation\n    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {\n        // Get the new view controller using segue.destinationViewController.\n        // Pass the selected object to the new view controller.\n    }\n    */\n\n    \n    // MARK: IBAction Methods\n    \n    @IBAction func addItem(_ sender: AnyObject) {\n        let addItemViewController = storyboard?.instantiateViewController(withIdentifier: \"idAddItem\") as! AddItemViewController\n        addItemViewController.presentAddItemViewControllerInViewController(originatingViewController: self) { (itemDescription, price) in\n            \n            DispatchQueue.main.async {\n                if self.items == nil {\n                    self.items = [[String: String]]()\n                }\n                \n                self.items.append([\"item\": itemDescription, \"price\": price])\n                self.tblInvoiceItems.reloadData()\n                \n                self.displayTotalAmount()\n            }\n        }\n    }\n    \n    \n    @IBAction func saveInvoice(_ sender: AnyObject) {\n        if saveCompletionHandler != nil {\n            if nextNumberAsString != nil {\n                UserDefaults.standard.set(nextNumberAsString, forKey: \"nextInvoiceNumber\")\n            }\n            else {\n                UserDefaults.standard.set(\"002\", forKey: \"nextInvoiceNumber\")\n            }\n            \n            saveCompletionHandler(_: invoiceNumber, _: tvRecipientInfo.text, _: bbiTotal.title!, _: items)\n            _ = navigationController?.popViewController(animated: true)\n        }\n    }\n    \n    \n    // MARK: Custom Methods\n    \n    func presentCreatorViewControllerInViewController(originalViewController: UIViewController, saveCompletionHandler: @escaping (_ invoiceNumber: String, _ recipientInfo: String, _ totalAmount: String, _ items: [[String: String]]) -> Void) {\n        self.saveCompletionHandler = saveCompletionHandler\n        originalViewController.navigationController?.pushViewController(self, animated: true)\n    }\n    \n    \n    func determineInvoiceNumber() {\n        // Get the invoice number from the user defaults if exists.\n        if let nextInvoiceNumber = UserDefaults.standard.object(forKey: \"nextInvoiceNumber\") {\n            invoiceNumber = nextInvoiceNumber as! String\n            \n            // Save the next invoice number to the user defaults.\n            let nextNumber = Int(nextInvoiceNumber as! String)! + 1\n            \n            if nextNumber < 10 {\n                nextNumberAsString = \"00\\(nextNumber)\"\n            }\n            else if nextNumber < 100 {\n                nextNumberAsString = \"0\\(nextNumber)\"\n            }\n            else {\n                nextNumberAsString = \"\\(nextNumber)\"\n            }\n        }\n        else {\n            // Specify the first invoice number.\n            invoiceNumber = \"001\"\n        }\n        \n        // Set the invoice number to the navigation bar's title.\n        navigationItem.title = invoiceNumber\n    }\n    \n    \n    func calculateTotalAmount() {\n        var total: Double = 0.0\n        if items != nil {\n            for invoiceItem in items {\n                let priceAsNumber = NumberFormatter().number(from: invoiceItem[\"price\"]!)\n                total += Double(priceAsNumber!)\n            }\n        }\n        \n        totalAmount = AppDelegate.getAppDelegate().getStringValueFormattedAsCurrency(value: \"\\(total)\")\n    }\n    \n    \n    func displayTotalAmount() {\n        calculateTotalAmount()\n        bbiTotal.title = totalAmount\n    }\n    \n    \n    func dismissKeyboard() {\n        if tvRecipientInfo.isFirstResponder {\n            tvRecipientInfo.resignFirstResponder()\n        }\n    }\n    \n    \n    // MARK: UITableView Delegate and Datasource Methods\n    \n    func numberOfSections(in tableView: UITableView) -> Int {\n        return 1\n    }\n    \n    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n        return (items != nil) ? items.count : 0\n    }\n    \n    \n    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n        var cell: UITableViewCell! = tableView.dequeueReusableCell(withIdentifier: \"itemCell\", for: indexPath as IndexPath)\n        \n        if cell == nil {\n            cell = UITableViewCell(style: UITableViewCellStyle.value1, reuseIdentifier: \"itemCell\")\n        }\n        \n        cell.textLabel?.text = items[indexPath.row][\"item\"]\n        cell.detailTextLabel?.text = AppDelegate.getAppDelegate().getStringValueFormattedAsCurrency(value: items[indexPath.row][\"price\"]!)\n        \n        return cell\n    }\n    \n    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {\n        return 60.0\n    }\n    \n\n    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {\n        if editingStyle == UITableViewCellEditingStyle.delete {\n            items.remove(at: indexPath.row)\n            tblInvoiceItems.reloadData()\n            displayTotalAmount()\n        }\n    }\n    \n}\n"
  },
  {
    "path": "Print2PDF/CustomPrintPageRenderer.swift",
    "content": "//\n//  CustomPrintPageRenderer.swift\n//  Print2PDF\n//\n//  Created by Gabriel Theodoropoulos on 24/06/16.\n//  Copyright © 2016 Appcoda. All rights reserved.\n//\n\nimport UIKit\n\nclass CustomPrintPageRenderer: UIPrintPageRenderer {\n\n    let A4PageWidth: CGFloat = 595.2\n    \n    let A4PageHeight: CGFloat = 841.8\n    \n    \n    override init() {\n        super.init()\n        \n        // Specify the frame of the A4 page.\n        let pageFrame = CGRect(x: 0.0, y: 0.0, width: A4PageWidth, height: A4PageHeight)\n        \n        // Set the page frame.\n        self.setValue(NSValue(cgRect: pageFrame), forKey: \"paperRect\")\n        \n        // Set the horizontal and vertical insets (that's optional).\n        // self.setValue(NSValue(CGRect: pageFrame), forKey: \"printableRect\")\n        self.setValue(NSValue(cgRect: pageFrame.insetBy(dx: 10.0, dy: 10.0)), forKey: \"printableRect\")\n        \n        \n        self.headerHeight = 50.0\n        self.footerHeight = 50.0\n    }\n    \n    \n    override func drawHeaderForPage(at pageIndex: Int, in headerRect: CGRect) {\n        // Specify the header text.\n        let headerText: NSString = \"Invoice\"\n        \n        // Set the desired font.\n        let font = UIFont(name: \"AmericanTypewriter-Bold\", size: 30.0)\n        \n        // Specify some text attributes we want to apply to the header text.\n        let textAttributes = [NSFontAttributeName: font!, NSForegroundColorAttributeName: UIColor(red: 243.0/255, green: 82.0/255.0, blue: 30.0/255.0, alpha: 1.0), NSKernAttributeName: 7.5] as [String : Any]\n        \n        // Calculate the text size.\n        let textSize = getTextSize(text: headerText as String, font: nil, textAttributes: textAttributes as [String : AnyObject]!)\n        \n        // Determine the offset to the right side.\n        let offsetX: CGFloat = 20.0\n        \n        // Specify the point that the text drawing should start from.\n        let pointX = headerRect.size.width - textSize.width - offsetX\n        let pointY = headerRect.size.height/2 - textSize.height/2\n        \n        // Draw the header text.\n        headerText.draw(at: CGPoint(x: pointX, y: pointY), withAttributes: textAttributes)\n    }\n    \n    \n    override func drawFooterForPage(at pageIndex: Int, in footerRect: CGRect) {\n        let footerText: NSString = \"Thank you!\"\n        \n        let font = UIFont(name: \"Noteworthy-Bold\", size: 14.0)\n        let textSize = getTextSize(text: footerText as String, font: font!)\n        \n        let centerX = footerRect.size.width/2 - textSize.width/2\n        let centerY = footerRect.origin.y + self.footerHeight/2 - textSize.height/2\n        let attributes = [NSFontAttributeName: font!, NSForegroundColorAttributeName: UIColor(red: 205.0/255.0, green: 205.0/255.0, blue: 205.0/255, alpha: 1.0)]\n        \n        footerText.draw(at: CGPoint(x: centerX, y: centerY), withAttributes: attributes)\n        \n        \n        // Draw a horizontal line.\n        let lineOffsetX: CGFloat = 20.0\n        let context = UIGraphicsGetCurrentContext()\n        context!.setStrokeColor(red: 205.0/255.0, green: 205.0/255.0, blue: 205.0/255, alpha: 1.0)\n        context!.move(to: CGPoint(x: lineOffsetX, y: footerRect.origin.y))\n        context!.addLine(to: CGPoint(x: footerRect.size.width - lineOffsetX, y: footerRect.origin.y))\n        context!.strokePath()\n    }\n    \n    \n    \n    func getTextSize(text: String, font: UIFont!, textAttributes: [String: AnyObject]! = nil) -> CGSize {\n        let testLabel = UILabel(frame: CGRect(x: 0.0, y: 0.0, width: self.paperRect.size.width, height: footerHeight))\n        if let attributes = textAttributes {\n            testLabel.attributedText = NSAttributedString(string: text, attributes: attributes)\n        }\n        else {\n            testLabel.text = text\n            testLabel.font = font!\n        }\n        \n        testLabel.sizeToFit()\n        \n        return testLabel.frame.size\n    }\n    \n}\n"
  },
  {
    "path": "Print2PDF/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>en</string>\n\t<key>CFBundleExecutable</key>\n\t<string>$(EXECUTABLE_NAME)</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>$(PRODUCT_NAME)</string>\n\t<key>CFBundlePackageType</key>\n\t<string>APPL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.0</string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>1</string>\n\t<key>LSRequiresIPhoneOS</key>\n\t<true/>\n\t<key>UILaunchStoryboardName</key>\n\t<string>LaunchScreen</string>\n\t<key>UIMainStoryboardFile</key>\n\t<string>Main</string>\n\t<key>UIRequiredDeviceCapabilities</key>\n\t<array>\n\t\t<string>armv7</string>\n\t</array>\n\t<key>UISupportedInterfaceOrientations</key>\n\t<array>\n\t\t<string>UIInterfaceOrientationPortrait</string>\n\t\t<string>UIInterfaceOrientationLandscapeLeft</string>\n\t\t<string>UIInterfaceOrientationLandscapeRight</string>\n\t</array>\n\t<key>UISupportedInterfaceOrientations~ipad</key>\n\t<array>\n\t\t<string>UIInterfaceOrientationPortrait</string>\n\t\t<string>UIInterfaceOrientationPortraitUpsideDown</string>\n\t\t<string>UIInterfaceOrientationLandscapeLeft</string>\n\t\t<string>UIInterfaceOrientationLandscapeRight</string>\n\t</array>\n\t<key>NSAppTransportSecurity</key>\n\t<dict>\n\t\t<key>NSAllowsArbitraryLoads</key>\n\t\t<true/>\n\t</dict>\n</dict>\n</plist>\n"
  },
  {
    "path": "Print2PDF/InvoiceComposer.swift",
    "content": "//\n//  InvoiceComposer.swift\n//  Print2PDF\n//\n//  Created by Gabriel Theodoropoulos on 23/06/16.\n//  Copyright © 2016 Appcoda. All rights reserved.\n//\n\nimport UIKit\n\nclass InvoiceComposer: NSObject {\n\n    let pathToInvoiceHTMLTemplate = Bundle.main.path(forResource: \"invoice\", ofType: \"html\")\n    \n    let pathToSingleItemHTMLTemplate = Bundle.main.path(forResource: \"single_item\", ofType: \"html\")\n    \n    let pathToLastItemHTMLTemplate = Bundle.main.path(forResource: \"last_item\", ofType: \"html\")\n    \n    let senderInfo = \"Gabriel Theodoropoulos<br>123 Somewhere Str.<br>10000 - MyCity<br>MyCountry\"\n    \n    let dueDate = \"\"\n    \n    let paymentMethod = \"Wire Transfer\"\n    \n    let logoImageURL = \"http://www.appcoda.com/wp-content/uploads/2015/12/blog-logo-dark-400.png\"\n    \n    var invoiceNumber: String!\n    \n    var pdfFilename: String!\n    \n    \n    override init() {\n        super.init()\n    }\n    \n    \n    func renderInvoice(invoiceNumber: String, invoiceDate: String, recipientInfo: String, items: [[String: String]], totalAmount: String) -> String! {\n        // Store the invoice number for future use.\n        self.invoiceNumber = invoiceNumber\n        \n        do {\n            // Load the invoice HTML template code into a String variable.\n            var HTMLContent = try String(contentsOfFile: pathToInvoiceHTMLTemplate!)\n            \n            // Replace all the placeholders with real values except for the items.\n            // The logo image.\n            HTMLContent = HTMLContent.replacingOccurrences(of: \"#LOGO_IMAGE#\", with: logoImageURL)\n            \n            // Invoice number.\n            HTMLContent = HTMLContent.replacingOccurrences(of: \"#INVOICE_NUMBER#\", with: invoiceNumber)\n            \n            // Invoice date.\n            HTMLContent = HTMLContent.replacingOccurrences(of: \"#INVOICE_DATE#\", with: invoiceDate)\n            \n            // Due date (we leave it blank by default).\n            HTMLContent = HTMLContent.replacingOccurrences(of: \"#DUE_DATE#\", with: dueDate)\n            \n            // Sender info.\n            HTMLContent = HTMLContent.replacingOccurrences(of: \"#SENDER_INFO#\", with: senderInfo)\n            \n            // Recipient info.\n            HTMLContent = HTMLContent.replacingOccurrences(of: \"#RECIPIENT_INFO#\", with: recipientInfo.replacingOccurrences(of: \"\\n\", with: \"<br>\"))\n            \n            // Payment method.\n            HTMLContent = HTMLContent.replacingOccurrences(of: \"#PAYMENT_METHOD#\", with: paymentMethod)\n            \n            // Total amount.\n            HTMLContent = HTMLContent.replacingOccurrences(of: \"#TOTAL_AMOUNT#\", with: totalAmount)\n            \n            // The invoice items will be added by using a loop.\n            var allItems = \"\"\n            \n            // For all the items except for the last one we'll use the \"single_item.html\" template.\n            // For the last one we'll use the \"last_item.html\" template.\n            for i in 0..<items.count {\n                var itemHTMLContent: String!\n                \n                // Determine the proper template file.\n                if i != items.count - 1 {\n                    itemHTMLContent = try String(contentsOfFile: pathToSingleItemHTMLTemplate!)\n                }\n                else {\n                    itemHTMLContent = try String(contentsOfFile: pathToLastItemHTMLTemplate!)\n                }\n                \n                // Replace the description and price placeholders with the actual values.\n                itemHTMLContent = itemHTMLContent.replacingOccurrences(of: \"#ITEM_DESC#\", with: items[i][\"item\"]!)\n                \n                // Format each item's price as a currency value.\n                let formattedPrice = AppDelegate.getAppDelegate().getStringValueFormattedAsCurrency(value: items[i][\"price\"]!)\n                itemHTMLContent = itemHTMLContent.replacingOccurrences(of: \"#PRICE#\", with: formattedPrice)\n                \n                // Add the item's HTML code to the general items string.\n                allItems += itemHTMLContent\n            }\n            \n            // Set the items.\n            HTMLContent = HTMLContent.replacingOccurrences(of: \"#ITEMS#\", with: allItems)\n            \n            // The HTML code is ready.\n            return HTMLContent\n            \n        }\n        catch {\n            print(\"Unable to open and use HTML template files.\")\n        }\n        \n        return nil\n    }\n    \n    \n    func exportHTMLContentToPDF(HTMLContent: String) {\n        let printPageRenderer = CustomPrintPageRenderer()\n        \n        let printFormatter = UIMarkupTextPrintFormatter(markupText: HTMLContent)\n        printPageRenderer.addPrintFormatter(printFormatter, startingAtPageAt: 0)\n        \n        let pdfData = drawPDFUsingPrintPageRenderer(printPageRenderer: printPageRenderer)\n        \n        pdfFilename = \"\\(AppDelegate.getAppDelegate().getDocDir())/Invoice\\(invoiceNumber!).pdf\"\n        pdfData?.write(toFile: pdfFilename, atomically: true)\n        \n        print(pdfFilename)\n    }\n    \n    \n    func drawPDFUsingPrintPageRenderer(printPageRenderer: UIPrintPageRenderer) -> NSData! {\n        let data = NSMutableData()\n        \n        UIGraphicsBeginPDFContextToData(data, CGRect.zero, nil)\n        for i in 0..<printPageRenderer.numberOfPages {\n            UIGraphicsBeginPDFPage()\n            printPageRenderer.drawPage(at: i, in: UIGraphicsGetPDFContextBounds())\n        }\n        \n        UIGraphicsEndPDFContext()\n        \n        return data\n    }\n    \n}\n"
  },
  {
    "path": "Print2PDF/InvoiceListViewController.swift",
    "content": "//\n//  InvoiceListViewController.swift\n//  Print2PDF\n//\n//  Created by Gabriel Theodoropoulos on 14/06/16.\n//  Copyright © 2016 Appcoda. All rights reserved.\n//\n\nimport UIKit\n\nclass InvoiceListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {\n\n    @IBOutlet weak var tblInvoices: UITableView!\n    \n    \n    var invoices: [[String: AnyObject]]!\n    \n    var selectedInvoiceIndex: Int!\n    \n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \n        tblInvoices.delegate = self\n        tblInvoices.dataSource = self\n    }\n\n    \n    override func viewWillAppear(_ animated: Bool) {\n        super.viewWillAppear(animated)\n        \n        if let inv = UserDefaults.standard.object(forKey: \"invoices\") {\n            invoices = inv as? [[String: AnyObject]]\n            tblInvoices.reloadData()\n        }\n    }\n    \n    \n    override func didReceiveMemoryWarning() {\n        super.didReceiveMemoryWarning()\n        // Dispose of any resources that can be recreated.\n    }\n    \n\n    \n    // MARK: - Navigation\n\n    // In a storyboard-based application, you will often want to do a little preparation before navigation\n    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {\n        if let identifier = segue.identifier {\n            if identifier == \"idSeguePresentPreview\" {\n                let previewViewController = segue.destination as! PreviewViewController\n                previewViewController.invoiceInfo = invoices[selectedInvoiceIndex]\n            }\n        }\n    }\n    \n\n    \n    // MARK: IBAction Methods\n    \n    @IBAction func createInvoice(_ sender: AnyObject) {\n        let creatorViewController = storyboard?.instantiateViewController(withIdentifier: \"idCreateInvoice\") as! CreatorViewController\n        creatorViewController.presentCreatorViewControllerInViewController(originalViewController: self) { (invoiceNumber, recipientInfo, totalAmount, items) in\n            DispatchQueue.main.async {\n                if self.invoices == nil {\n                    self.invoices = [[String: AnyObject]]()\n                }\n                \n                // Add the new invoice data to the invoices array.\n                self.invoices.append([\"invoiceNumber\": invoiceNumber as AnyObject, \"invoiceDate\": self.formatAndGetCurrentDate() as AnyObject, \"recipientInfo\": recipientInfo as AnyObject, \"totalAmount\": totalAmount as AnyObject, \"items\": items as AnyObject])\n                \n                // Update the user defaults with the new invoice.\n                UserDefaults.standard.set(self.invoices, forKey: \"invoices\")\n                \n                // Reload the tableview.\n                self.tblInvoices.reloadData()\n            }\n        }\n    }\n    \n    \n    // MARK: Custom Methods\n    \n    func formatAndGetCurrentDate() -> String {\n        let dateFormatter = DateFormatter()\n        dateFormatter.dateStyle = DateFormatter.Style.medium\n        return dateFormatter.string(from: NSDate() as Date)\n    }\n    \n    \n    // MARK: UITableView Delegate and Datasource Methods\n    \n    func numberOfSections(in tableView: UITableView) -> Int {\n        return 1\n    }\n    \n    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n        return (invoices != nil) ? invoices.count : 0\n    }\n    \n    \n    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n        var cell: UITableViewCell! = tableView.dequeueReusableCell(withIdentifier: \"invoiceCell\", for: indexPath as IndexPath)\n        \n        if cell == nil {\n            cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: \"invoiceCell\")\n        }\n        \n        cell.textLabel?.text = \"\\(invoices[indexPath.row][\"invoiceNumber\"] as! String) - \\(invoices[indexPath.row][\"invoiceDate\"] as! String) - \\(invoices[indexPath.row][\"totalAmount\"] as! String)\"\n        \n        return cell\n    }\n    \n    \n    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {\n        return 60.0\n    }\n    \n    \n    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {\n        selectedInvoiceIndex = indexPath.row\n        performSegue(withIdentifier: \"idSeguePresentPreview\", sender: self)\n    }\n    \n    \n    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {\n        if editingStyle == UITableViewCellEditingStyle.delete {\n            invoices.remove(at: indexPath.row)\n            tblInvoices.reloadData()\n            UserDefaults.standard.set(self.invoices, forKey: \"invoices\")\n        }\n    }\n    \n    \n}\n"
  },
  {
    "path": "Print2PDF/PreviewViewController.swift",
    "content": "//\n//  PreviewViewController.swift\n//  Print2PDF\n//\n//  Created by Gabriel Theodoropoulos on 14/06/16.\n//  Copyright © 2016 Appcoda. All rights reserved.\n//\n\nimport UIKit\nimport MessageUI\n\n\nclass PreviewViewController: UIViewController {\n\n    @IBOutlet weak var webPreview: UIWebView!\n    \n    var invoiceInfo: [String: AnyObject]!\n    \n    var invoiceComposer: InvoiceComposer!\n    \n    var HTMLContent: String!\n    \n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        // Do any additional setup after loading the view.\n    }\n\n    \n    override func viewWillAppear(_ animated: Bool) {\n        super.viewWillAppear(animated)\n        \n        createInvoiceAsHTML()\n    }\n    \n    \n    override func didReceiveMemoryWarning() {\n        super.didReceiveMemoryWarning()\n        // Dispose of any resources that can be recreated.\n    }\n    \n\n    /*\n    // MARK: - Navigation\n\n    // In a storyboard-based application, you will often want to do a little preparation before navigation\n    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {\n        // Get the new view controller using segue.destinationViewController.\n        // Pass the selected object to the new view controller.\n    }\n    */\n\n    // MARK: IBAction Methods\n    \n    \n    @IBAction func exportToPDF(_ sender: AnyObject) {\n        invoiceComposer.exportHTMLContentToPDF(HTMLContent: HTMLContent)\n        showOptionsAlert()\n    }\n    \n    \n    // MARK: Custom Methods\n    \n    func createInvoiceAsHTML() {\n        invoiceComposer = InvoiceComposer()\n        if let invoiceHTML = invoiceComposer.renderInvoice(invoiceNumber: invoiceInfo[\"invoiceNumber\"] as! String,\n                                                           invoiceDate: invoiceInfo[\"invoiceDate\"] as! String,\n                                                           recipientInfo: invoiceInfo[\"recipientInfo\"] as! String,\n                                                           items: invoiceInfo[\"items\"] as! [[String: String]],\n                                                           totalAmount: invoiceInfo[\"totalAmount\"] as! String) {\n            \n            webPreview.loadHTMLString(invoiceHTML, baseURL: NSURL(string: invoiceComposer.pathToInvoiceHTMLTemplate!)! as URL)\n            HTMLContent = invoiceHTML\n        }\n    }\n    \n    \n    \n    func showOptionsAlert() {\n        let alertController = UIAlertController(title: \"Yeah!\", message: \"Your invoice has been successfully printed to a PDF file.\\n\\nWhat do you want to do now?\", preferredStyle: UIAlertControllerStyle.alert)\n        \n        let actionPreview = UIAlertAction(title: \"Preview it\", style: UIAlertActionStyle.default) { (action) in\n            if let filename = self.invoiceComposer.pdfFilename, let url = URL(string: filename) {\n                let request = URLRequest(url: url)\n                self.webPreview.loadRequest(request)\n            }\n        }\n        \n        let actionEmail = UIAlertAction(title: \"Send by Email\", style: UIAlertActionStyle.default) { (action) in\n            DispatchQueue.main.async {\n                self.sendEmail()\n            }\n        }\n        \n        let actionNothing = UIAlertAction(title: \"Nothing\", style: UIAlertActionStyle.default) { (action) in\n            \n        }\n        \n        alertController.addAction(actionPreview)\n        alertController.addAction(actionEmail)\n        alertController.addAction(actionNothing)\n        \n        present(alertController, animated: true, completion: nil)\n    }\n    \n    \n    \n    func sendEmail() {\n        if MFMailComposeViewController.canSendMail() {\n            let mailComposeViewController = MFMailComposeViewController()\n            mailComposeViewController.setSubject(\"Invoice\")\n            mailComposeViewController.addAttachmentData(NSData(contentsOfFile: invoiceComposer.pdfFilename)! as Data, mimeType: \"application/pdf\", fileName: \"Invoice\")\n            present(mailComposeViewController, animated: true, completion: nil)\n        }\n    }\n    \n}\n"
  },
  {
    "path": "Print2PDF.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\tC04F22BD1D1C32280090D56B /* InvoiceComposer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04F22BC1D1C32280090D56B /* InvoiceComposer.swift */; };\n\t\tC091D2511D1D40CA008DBE68 /* CustomPrintPageRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C091D2501D1D40CA008DBE68 /* CustomPrintPageRenderer.swift */; };\n\t\tC0C922211D0FFDE5000D4607 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0C922201D0FFDE5000D4607 /* AppDelegate.swift */; };\n\t\tC0C922261D0FFDE5000D4607 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0C922241D0FFDE5000D4607 /* Main.storyboard */; };\n\t\tC0C922281D0FFDE6000D4607 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C0C922271D0FFDE6000D4607 /* Assets.xcassets */; };\n\t\tC0C9222B1D0FFDE6000D4607 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0C922291D0FFDE6000D4607 /* LaunchScreen.storyboard */; };\n\t\tC0C922331D0FFE1B000D4607 /* InvoiceListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0C922321D0FFE1B000D4607 /* InvoiceListViewController.swift */; };\n\t\tC0C922351D0FFE67000D4607 /* CreatorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0C922341D0FFE67000D4607 /* CreatorViewController.swift */; };\n\t\tC0C922371D1002C4000D4607 /* AddItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0C922361D1002C4000D4607 /* AddItemViewController.swift */; };\n\t\tC0C9223C1D10585C000D4607 /* invoice.html in Resources */ = {isa = PBXBuildFile; fileRef = C0C922391D10585C000D4607 /* invoice.html */; };\n\t\tC0C9223D1D10585C000D4607 /* last_item.html in Resources */ = {isa = PBXBuildFile; fileRef = C0C9223A1D10585C000D4607 /* last_item.html */; };\n\t\tC0C9223E1D10585C000D4607 /* single_item.html in Resources */ = {isa = PBXBuildFile; fileRef = C0C9223B1D10585C000D4607 /* single_item.html */; };\n\t\tC0C922401D105886000D4607 /* PreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0C9223F1D105886000D4607 /* PreviewViewController.swift */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXFileReference section */\n\t\tC04F22BC1D1C32280090D56B /* InvoiceComposer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InvoiceComposer.swift; sourceTree = \"<group>\"; };\n\t\tC091D2501D1D40CA008DBE68 /* CustomPrintPageRenderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomPrintPageRenderer.swift; sourceTree = \"<group>\"; };\n\t\tC0C9221D1D0FFDE5000D4607 /* Print2PDF.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Print2PDF.app; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\tC0C922201D0FFDE5000D4607 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = \"<group>\"; };\n\t\tC0C922251D0FFDE5000D4607 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = \"<group>\"; };\n\t\tC0C922271D0FFDE6000D4607 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = \"<group>\"; };\n\t\tC0C9222A1D0FFDE6000D4607 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = \"<group>\"; };\n\t\tC0C9222C1D0FFDE6000D4607 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n\t\tC0C922321D0FFE1B000D4607 /* InvoiceListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InvoiceListViewController.swift; sourceTree = \"<group>\"; };\n\t\tC0C922341D0FFE67000D4607 /* CreatorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreatorViewController.swift; sourceTree = \"<group>\"; };\n\t\tC0C922361D1002C4000D4607 /* AddItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddItemViewController.swift; sourceTree = \"<group>\"; };\n\t\tC0C922391D10585C000D4607 /* invoice.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = invoice.html; sourceTree = \"<group>\"; };\n\t\tC0C9223A1D10585C000D4607 /* last_item.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = last_item.html; sourceTree = \"<group>\"; };\n\t\tC0C9223B1D10585C000D4607 /* single_item.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = single_item.html; sourceTree = \"<group>\"; };\n\t\tC0C9223F1D105886000D4607 /* PreviewViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreviewViewController.swift; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\tC0C9221A1D0FFDE5000D4607 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\tC0C922141D0FFDE5000D4607 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tC0C922381D105847000D4607 /* HTML Templates */,\n\t\t\t\tC0C9221F1D0FFDE5000D4607 /* Print2PDF */,\n\t\t\t\tC0C9221E1D0FFDE5000D4607 /* Products */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tC0C9221E1D0FFDE5000D4607 /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tC0C9221D1D0FFDE5000D4607 /* Print2PDF.app */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tC0C9221F1D0FFDE5000D4607 /* Print2PDF */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tC0C922201D0FFDE5000D4607 /* AppDelegate.swift */,\n\t\t\t\tC0C922321D0FFE1B000D4607 /* InvoiceListViewController.swift */,\n\t\t\t\tC0C922341D0FFE67000D4607 /* CreatorViewController.swift */,\n\t\t\t\tC0C922361D1002C4000D4607 /* AddItemViewController.swift */,\n\t\t\t\tC0C9223F1D105886000D4607 /* PreviewViewController.swift */,\n\t\t\t\tC04F22BC1D1C32280090D56B /* InvoiceComposer.swift */,\n\t\t\t\tC091D2501D1D40CA008DBE68 /* CustomPrintPageRenderer.swift */,\n\t\t\t\tC0C922241D0FFDE5000D4607 /* Main.storyboard */,\n\t\t\t\tC0C922271D0FFDE6000D4607 /* Assets.xcassets */,\n\t\t\t\tC0C922291D0FFDE6000D4607 /* LaunchScreen.storyboard */,\n\t\t\t\tC0C9222C1D0FFDE6000D4607 /* Info.plist */,\n\t\t\t);\n\t\t\tpath = Print2PDF;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tC0C922381D105847000D4607 /* HTML Templates */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\tC0C922391D10585C000D4607 /* invoice.html */,\n\t\t\t\tC0C9223A1D10585C000D4607 /* last_item.html */,\n\t\t\t\tC0C9223B1D10585C000D4607 /* single_item.html */,\n\t\t\t);\n\t\t\tname = \"HTML Templates\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXNativeTarget section */\n\t\tC0C9221C1D0FFDE5000D4607 /* Print2PDF */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = C0C9222F1D0FFDE6000D4607 /* Build configuration list for PBXNativeTarget \"Print2PDF\" */;\n\t\t\tbuildPhases = (\n\t\t\t\tC0C922191D0FFDE5000D4607 /* Sources */,\n\t\t\t\tC0C9221A1D0FFDE5000D4607 /* Frameworks */,\n\t\t\t\tC0C9221B1D0FFDE5000D4607 /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = Print2PDF;\n\t\t\tproductName = Print2PDF;\n\t\t\tproductReference = C0C9221D1D0FFDE5000D4607 /* Print2PDF.app */;\n\t\t\tproductType = \"com.apple.product-type.application\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\tC0C922151D0FFDE5000D4607 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastSwiftUpdateCheck = 0730;\n\t\t\t\tLastUpgradeCheck = 0730;\n\t\t\t\tORGANIZATIONNAME = Appcoda;\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\tC0C9221C1D0FFDE5000D4607 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 7.3;\n\t\t\t\t\t\tLastSwiftMigration = 0800;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = C0C922181D0FFDE5000D4607 /* Build configuration list for PBXProject \"Print2PDF\" */;\n\t\t\tcompatibilityVersion = \"Xcode 3.2\";\n\t\t\tdevelopmentRegion = English;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t\tBase,\n\t\t\t);\n\t\t\tmainGroup = C0C922141D0FFDE5000D4607;\n\t\t\tproductRefGroup = C0C9221E1D0FFDE5000D4607 /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\tC0C9221C1D0FFDE5000D4607 /* Print2PDF */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\tC0C9221B1D0FFDE5000D4607 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\tC0C9223C1D10585C000D4607 /* invoice.html in Resources */,\n\t\t\t\tC0C9223D1D10585C000D4607 /* last_item.html in Resources */,\n\t\t\t\tC0C9222B1D0FFDE6000D4607 /* LaunchScreen.storyboard in Resources */,\n\t\t\t\tC0C922281D0FFDE6000D4607 /* Assets.xcassets in Resources */,\n\t\t\t\tC0C922261D0FFDE5000D4607 /* Main.storyboard in Resources */,\n\t\t\t\tC0C9223E1D10585C000D4607 /* single_item.html in Resources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\tC0C922191D0FFDE5000D4607 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\tC0C922371D1002C4000D4607 /* AddItemViewController.swift in Sources */,\n\t\t\t\tC0C922351D0FFE67000D4607 /* CreatorViewController.swift in Sources */,\n\t\t\t\tC091D2511D1D40CA008DBE68 /* CustomPrintPageRenderer.swift in Sources */,\n\t\t\t\tC0C922211D0FFDE5000D4607 /* AppDelegate.swift in Sources */,\n\t\t\t\tC0C922401D105886000D4607 /* PreviewViewController.swift in Sources */,\n\t\t\t\tC0C922331D0FFE1B000D4607 /* InvoiceListViewController.swift in Sources */,\n\t\t\t\tC04F22BD1D1C32280090D56B /* InvoiceComposer.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXVariantGroup section */\n\t\tC0C922241D0FFDE5000D4607 /* Main.storyboard */ = {\n\t\t\tisa = PBXVariantGroup;\n\t\t\tchildren = (\n\t\t\t\tC0C922251D0FFDE5000D4607 /* Base */,\n\t\t\t);\n\t\t\tname = Main.storyboard;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\tC0C922291D0FFDE6000D4607 /* LaunchScreen.storyboard */ = {\n\t\t\tisa = PBXVariantGroup;\n\t\t\tchildren = (\n\t\t\t\tC0C9222A1D0FFDE6000D4607 /* Base */,\n\t\t\t);\n\t\t\tname = LaunchScreen.storyboard;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXVariantGroup section */\n\n/* Begin XCBuildConfiguration section */\n\t\tC0C9222D1D0FFDE6000D4607 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 9.3;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\tC0C9222E1D0FFDE6000D4607 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 9.3;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t\tVALIDATE_PRODUCT = YES;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\tC0C922301D0FFDE6000D4607 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n\t\t\t\tINFOPLIST_FILE = Print2PDF/Info.plist;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.appcoda.Print2PDF;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_VERSION = 3.0;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\tC0C922311D0FFDE6000D4607 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n\t\t\t\tINFOPLIST_FILE = Print2PDF/Info.plist;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.appcoda.Print2PDF;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_VERSION = 3.0;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\tC0C922181D0FFDE5000D4607 /* Build configuration list for PBXProject \"Print2PDF\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\tC0C9222D1D0FFDE6000D4607 /* Debug */,\n\t\t\t\tC0C9222E1D0FFDE6000D4607 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\tC0C9222F1D0FFDE6000D4607 /* Build configuration list for PBXNativeTarget \"Print2PDF\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\tC0C922301D0FFDE6000D4607 /* Debug */,\n\t\t\t\tC0C922311D0FFDE6000D4607 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = C0C922151D0FFDE5000D4607 /* Project object */;\n}\n"
  },
  {
    "path": "README.md",
    "content": "# Print2PDF in iOS\n\nIt is an invoice demo showing you how to create PDF documents using HTML templates in iOS. For full tutorial, please refer to the link below:\n\nhttp://www.appcoda.com/pdf-generation-ios/\n"
  },
  {
    "path": "invoice.html",
    "content": "<!DOCTYPE html>\n<html>\n    <head>\n        <meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">\n            <title>A simple, clean, and responsive HTML invoice template</title>\n            <style>\n                .invoice-box{\n                    max-width:800px;\n                    margin:auto;\n                    padding:30px;\n                    /*border:1px solid #eee;*/\n                    /*box-shadow:0 0 10px rgba(0, 0, 0, .15); */\n                    font-size:16px;\n                    line-height:24px;\n                    font-family:'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;\n                    color:#555;\n                }\n            \n            .invoice-box table{\n                width:100%;\n                line-height:inherit;\n                text-align:left;\n            }\n            \n            .invoice-box table td{\n                padding:5px;\n                vertical-align:top;\n            }\n            \n            .invoice-box table tr td:nth-child(2){\n                text-align:right;\n            }\n            \n            .invoice-box table tr.top table td{\n                padding-bottom:20px;\n            }\n            \n            .invoice-box table tr.top table td.title{\n                font-size:45px;\n                line-height:45px;\n                color:#333;\n            }\n            \n            .invoice-box table tr.information table td{\n                padding-bottom:40px;\n            }\n            \n            .invoice-box table tr.heading td{\n                background:#eee;\n                border-bottom:1px solid #ddd;\n                font-weight:bold;\n            }\n            \n            .invoice-box table tr.details td{\n                padding-bottom:20px;\n            }\n            \n            .invoice-box table tr.item td{\n                border-bottom:1px solid #eee;\n            }\n            \n            .invoice-box table tr.item.last td{\n                border-bottom:none;\n            }\n            \n            .invoice-box table tr.total td:nth-child(2){\n                border-top:2px solid #eee;\n                font-weight:bold;\n            }\n            \n            @media only screen and (max-width: 600px) {\n                .invoice-box table tr.top table td{\n                    width:100%;\n                    display:block;\n                    text-align:center;\n                }\n                \n                .invoice-box table tr.information table td{\n                    width:100%;\n                    display:block;\n                    text-align:center;\n                }\n            }\n            </style>\n            </head>\n    <body>\n        <div class=\"invoice-box\">\n            <table cellpadding=\"0\" cellspacing=\"0\">\n                <tbody>\n                    <tr class=\"top\">\n                        <td colspan=\"2\">\n                            <table>\n                                <tbody>\n                                    <tr>\n                                        <td class=\"title\"> <img src=\"#LOGO_IMAGE#\" style=\"width:100%; max-width:300px; background-color: #cdcdcd\">\n                                            </td>\n                                        <td> Invoice #: #INVOICE_NUMBER#<br>\n                                            #INVOICE_DATE#<br>\n                                            #DUE_DATE# </td>\n                                    </tr>\n                                </tbody>\n                            </table>\n                        </td>\n                    </tr>\n                    <tr class=\"information\">\n                        <td colspan=\"2\">\n                            <table>\n                                <tbody>\n                                    <tr>\n                                        <td> #SENDER_INFO# </td>\n                                        <td> #RECIPIENT_INFO# </td>\n                                    </tr>\n                                </tbody>\n                            </table>\n                        </td>\n                    </tr>\n                    <tr class=\"heading\">\n                        <td> Payment Method </td>\n                        <td> <br>\n                        </td>\n                    </tr>\n                    <tr class=\"details\">\n                        <td> #PAYMENT_METHOD# </td>\n                        <td> <br>\n                        </td>\n                    </tr>\n                    <tr class=\"heading\">\n                        <td> Item </td>\n                        <td> Price </td>\n                    </tr>\n                    #ITEMS#\n                    <tr class=\"total\">\n                        <td><br>\n                        </td>\n                        <td> Total: #TOTAL_AMOUNT# </td>\n                    </tr>\n                </tbody>\n            </table>\n        </div>\n        \n    </body>\n</html>\n"
  },
  {
    "path": "last_item.html",
    "content": "<tr class=\"item last\">\n\t<td>#ITEM_DESC#</td>\n\t<td>#PRICE#</td>\n</tr>\n"
  },
  {
    "path": "single_item.html",
    "content": "<tr class=\"item\">\n\t<td>#ITEM_DESC#</td>\n\t<td>#PRICE#</td>\n</tr>\n"
  }
]