Jelajahi Sumber

update project

Marino Faggiana 6 tahun lalu
induk
melakukan
5905b007c4
53 mengubah file dengan 1920 tambahan dan 43 penghapusan
  1. 1 0
      Cartfile
  2. 1 0
      Cartfile.resolved
  3. 64 0
      Carthage/Checkouts/PDFGenerator/.gitignore
  4. 2 0
      Carthage/Checkouts/PDFGenerator/.hound.yml
  5. 1 0
      Carthage/Checkouts/PDFGenerator/.swift-version
  6. 34 0
      Carthage/Checkouts/PDFGenerator/.swiftlint.yml
  7. 29 0
      Carthage/Checkouts/PDFGenerator/.travis.yml
  8. 74 0
      Carthage/Checkouts/PDFGenerator/CHANGELOG.md
  9. 43 0
      Carthage/Checkouts/PDFGenerator/Demo/AppDelegate.swift
  10. 38 0
      Carthage/Checkouts/PDFGenerator/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json
  11. 27 0
      Carthage/Checkouts/PDFGenerator/Demo/Base.lproj/LaunchScreen.storyboard
  12. 93 0
      Carthage/Checkouts/PDFGenerator/Demo/Base.lproj/Main.storyboard
  13. 45 0
      Carthage/Checkouts/PDFGenerator/Demo/Info.plist
  14. 93 0
      Carthage/Checkouts/PDFGenerator/Demo/PDFOutput.storyboard
  15. 50 0
      Carthage/Checkouts/PDFGenerator/Demo/PDFOutputViewController.swift
  16. 67 0
      Carthage/Checkouts/PDFGenerator/Demo/PDFPreviewVC.storyboard
  17. 37 0
      Carthage/Checkouts/PDFGenerator/Demo/PDFPreviewVC.swift
  18. 36 0
      Carthage/Checkouts/PDFGenerator/Demo/PDFViewController.storyboard
  19. 29 0
      Carthage/Checkouts/PDFGenerator/Demo/PDFViewController.swift
  20. 23 0
      Carthage/Checkouts/PDFGenerator/Demo/SampleTableViewCell.swift
  21. 70 0
      Carthage/Checkouts/PDFGenerator/Demo/SampleTableViewController.storyboard
  22. 112 0
      Carthage/Checkouts/PDFGenerator/Demo/SampleTableViewController.swift
  23. 151 0
      Carthage/Checkouts/PDFGenerator/Demo/ViewController.swift
  24. 57 0
      Carthage/Checkouts/PDFGenerator/Demo/WebViewController.storyboard
  25. 56 0
      Carthage/Checkouts/PDFGenerator/Demo/WebViewController.swift
  26. TEMPAT SAMPAH
      Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_0.jpg
  27. TEMPAT SAMPAH
      Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_1.jpg
  28. TEMPAT SAMPAH
      Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_2.jpg
  29. TEMPAT SAMPAH
      Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_3.jpg
  30. TEMPAT SAMPAH
      Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_4.jpg
  31. TEMPAT SAMPAH
      Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_5.jpg
  32. 21 0
      Carthage/Checkouts/PDFGenerator/LICENSE
  33. 14 0
      Carthage/Checkouts/PDFGenerator/PDFGenerator.podspec
  34. 0 0
      Carthage/Checkouts/PDFGenerator/PDFGenerator/DPIType.swift
  35. 0 0
      Carthage/Checkouts/PDFGenerator/PDFGenerator/FilePathConvertible.swift
  36. 26 0
      Carthage/Checkouts/PDFGenerator/PDFGenerator/Info.plist
  37. 0 0
      Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFGenerateError.swift
  38. 0 0
      Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFGenerator.h
  39. 0 0
      Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFGenerator.swift
  40. 0 0
      Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFPage.swift
  41. 0 0
      Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFPageRenderable.swift
  42. 4 4
      Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFPassword.swift
  43. 19 0
      Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/DPITests.swift
  44. 29 0
      Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/FilePathConvertibleTests.swift
  45. TEMPAT SAMPAH
      Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/Images/test_image1.png
  46. 24 0
      Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/Info.plist
  47. 462 0
      Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/PDFGeneratorTests.swift
  48. 71 0
      Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/PDFPasswordTests.swift
  49. 3 0
      Carthage/Checkouts/PDFGenerator/Package.swift
  50. 6 0
      Carthage/Checkouts/PDFGenerator/codecov.yml
  51. 6 39
      Nextcloud.xcodeproj/project.pbxproj
  52. 1 0
      iOSClient/Main/CCCreateCloud.swift
  53. 1 0
      iOSClient/Scan/ScanCollectionView.swift

+ 1 - 0
Cartfile

@@ -1,3 +1,4 @@
 github "tilltue/TLPhotoPicker"
 github "kishikawakatsumi/UICKeyChainStore"
 github "danielsaidi/Sheeeeeeeeet"
+github "sgr-ksmt/PDFGenerator" ~> 2.1

+ 1 - 0
Cartfile.resolved

@@ -1,3 +1,4 @@
 github "danielsaidi/Sheeeeeeeeet" "1.0.1"
 github "kishikawakatsumi/UICKeyChainStore" "v2.1.2"
+github "sgr-ksmt/PDFGenerator" "2.1"
 github "tilltue/TLPhotoPicker" "1.7.7"

+ 64 - 0
Carthage/Checkouts/PDFGenerator/.gitignore

@@ -0,0 +1,64 @@
+# Xcode
+#
+# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
+
+## Build generated
+build/
+DerivedData
+
+## Various settings
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+xcuserdata
+
+## Other
+*.xccheckout
+*.moved-aside
+*.xcuserstate
+*.xcscmblueprint
+*.DS_Store
+
+## Obj-C/Swift specific
+*.hmap
+*.ipa
+
+## Playgrounds
+timeline.xctimeline
+playground.xcworkspace
+
+# Swift Package Manager
+#
+# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
+# Packages/
+.build/
+
+# CocoaPods
+#
+# We recommend against adding the Pods directory to your .gitignore. However
+# you should judge for yourself, the pros and cons are mentioned at:
+# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
+#
+# Pods/
+
+# Carthage
+#
+# Add this line if you want to avoid checking in source code from Carthage dependencies.
+# Carthage/Checkouts
+
+Carthage/Build
+
+# fastlane
+#
+# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
+# screenshots whenever they are needed.
+# For more information about the recommended setup visit:
+# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md
+
+fastlane/report.xml
+fastlane/screenshots

+ 2 - 0
Carthage/Checkouts/PDFGenerator/.hound.yml

@@ -0,0 +1,2 @@
+swift:
+  config_file: .swiftlint.yml

+ 1 - 0
Carthage/Checkouts/PDFGenerator/.swift-version

@@ -0,0 +1 @@
+4.0

+ 34 - 0
Carthage/Checkouts/PDFGenerator/.swiftlint.yml

@@ -0,0 +1,34 @@
+opt_in_rules:
+- trailing_newline
+
+disabled_rules:
+- trailing_whitespace
+- type_name
+- force_cast
+- type_body_length
+- file_length
+- variable_name
+- cyclomatic_complexity
+- valid_docs
+- missing_docs
+- opening_brace
+- line_length
+- force_try
+
+force_try: warning
+
+line_length: 150
+
+excluded: # Lint対象から外すファイルのあるパスを記述
+- Pods
+- Carthage
+
+# 関数の長さ
+function_body_length:
+- 100 # warning
+- 300 # error
+
+# 引数の数
+function_parameter_count:
+- 5 #warning
+- 10 #error

+ 29 - 0
Carthage/Checkouts/PDFGenerator/.travis.yml

@@ -0,0 +1,29 @@
+language: objective-c
+osx_image: xcode9
+xcode_project: PDFGenerator.xcodeproj
+xcode_scheme: PDFGenerator
+env:
+  global:
+  - DESTINATION="platform=iOS Simulator,name=iPhone 8"
+  - FRAMEWORK_NAME=PDFGenerator
+branches:
+  only:
+  - master
+  - "/bugfix.*/"
+  - "/^develop.*/"
+  - "/^v?[0-9\\.]+/"
+
+before_install:
+  - export IOS_SIMULATOR_UDID=$(instruments -s devices | grep "$ios_device ($ios_version)" | sed -E 's/.*\[([0-9A-F-]+)\].*/\1/g')
+  - echo "Prelaunching iOS simulator $IOS_SIMULATOR_UDID"
+  - open -a "simulator" --args -CurrentDeviceUDID $IOS_SIMULATOR_UDID
+
+script:
+- if [[ "$JOB" == "Xcode7.3" ]]; then pod lib lint; fi
+- set -o pipefail
+- xcodebuild test -project "$TRAVIS_XCODE_PROJECT" -scheme "$TRAVIS_XCODE_SCHEME" -sdk iphonesimulator -destination "$DESTINATION" | xcpretty -c
+after_success:
+  - bash <(curl -s https://codecov.io/bash)
+before_deploy:
+- carthage build --no-skip-current
+- carthage archive "$FRAMEWORK_NAME"

+ 74 - 0
Carthage/Checkouts/PDFGenerator/CHANGELOG.md

@@ -0,0 +1,74 @@
+#Change Log
+
+## [v2.1](https://github.com/sgr-ksmt/PDFGenerator/releases/tag/2.1) (2017/09/21)
+### Updated
+- Update project to xcode9 and swift4 (#79)
+
+### Fixed
+- Cleanup (#77)
+
+Special thanks!!  **wesbillman** , **russellbstephens**
+
+
+## [v2.0.1](https://github.com/sgr-ksmt/PDFGenerator/releases/tag/2.0.1) (2016/09/19)
+Minor bug fix
+### Fixed
+- Fix generate as Data issue using `PDFGenerator.generated(by:)` #54
+
+
+## [v2.0.0](https://github.com/sgr-ksmt/PDFGenerator/releases/tag/2.0.0) (2016/09/15)
+Major update :point_up::point_up:
+### Improvement
+- Support Swift3.0
+
+
+## [v1.4.2](https://github.com/sgr-ksmt/PDFGenerator/releases/tag/1.4.0) (2016/09/08)
+### Fixed
+- Fix minor bugs #40
+
+## [v1.4.0](https://github.com/sgr-ksmt/PDFGenerator/releases/tag/1.4.0) (2016/07/23)
+### Added
+- FilePathConvertible : `outputPath` is allowed both `String` and `NSURL`.  #38
+- CHANGELOG.md
+- codecov #37
+
+### Updated
+- Add more UnitTest : codecov percentage increase to 92%. #39
+
+## Swift3.0 support (beta)
+- compatible to Swift 3.0 #29 #31 #32
+
+## [v1.3.0](https://github.com/sgr-ksmt/PDFGenerator/releases/tag/1.3.0) (2016/07/12)
+### Implemented
+- Password Protection #34
+
+
+## [v1.2.0](https://github.com/sgr-ksmt/PDFGenerator/releases/tag/1.2.0) (2016/06/22)
+### Implemented
+- DPI suppoert #27
+
+## [v1.1.4](https://github.com/sgr-ksmt/PDFGenerator/releases/tag/1.1.4) (2016/06/22)
+### Updated
+- Update for Xcode7.3(swift2.2) #21
+
+## 1.1.3~1.1.1
+### Fixed
+- Fix minor bugs #18, #13
+
+## [v1.1.0](https://github.com/sgr-ksmt/PDFGenerator/releases/tag/1.1.0) (2016/02/20)
+### Added
+- support Binary,ImageRef render. #11
+
+## [v1.0.0](https://github.com/sgr-ksmt/PDFGenerator/releases/tag/1.0.0) (2016/02/11)
+### Stable Version Release!!
+- Support multiple pages.
+- Also generate PDF from imagePath that can load image with UIImage(contentsOfFile:)
+- Type safe.
+- Good memory management.
+- Generate PDF from mixed-pages.
+- If view is UIScrollView , drawn whole content.
+- Outputs as NSData or writes to Disk(in given file path) directly.
+- Corresponding to Error-Handling. Strange PDF has never been generated!!
+
+## 0.2.0 ~ 0.1.0
+- beta release

+ 43 - 0
Carthage/Checkouts/PDFGenerator/Demo/AppDelegate.swift

@@ -0,0 +1,43 @@
+//
+//  AppDelegate.swift
+//  Demo
+//
+//  Created by Suguru Kishimoto on 2016/02/04.
+//
+//
+
+import UIKit
+
+@UIApplicationMain
+class AppDelegate: UIResponder, UIApplicationDelegate {
+
+    var window: UIWindow?
+
+    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
+        // Override point for customization after application launch.
+        return true
+    }
+
+    func applicationWillResignActive(_ application: UIApplication) {
+        // 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.
+        // 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.
+    }
+
+    func applicationDidEnterBackground(_ application: UIApplication) {
+        // 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.
+        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+    }
+
+    func applicationWillEnterForeground(_ application: UIApplication) {
+        // 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.
+    }
+
+    func applicationDidBecomeActive(_ application: UIApplication) {
+        // 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.
+    }
+
+    func applicationWillTerminate(_ application: UIApplication) {
+        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+    }
+
+}

+ 38 - 0
Carthage/Checkouts/PDFGenerator/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json

@@ -0,0 +1,38 @@
+{
+  "images" : [
+    {
+      "idiom" : "iphone",
+      "size" : "29x29",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "iphone",
+      "size" : "29x29",
+      "scale" : "3x"
+    },
+    {
+      "idiom" : "iphone",
+      "size" : "40x40",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "iphone",
+      "size" : "40x40",
+      "scale" : "3x"
+    },
+    {
+      "idiom" : "iphone",
+      "size" : "60x60",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "iphone",
+      "size" : "60x60",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

+ 27 - 0
Carthage/Checkouts/PDFGenerator/Demo/Base.lproj/LaunchScreen.storyboard

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<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">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
+    </dependencies>
+    <scenes>
+        <!--View Controller-->
+        <scene sceneID="EHf-IW-A2E">
+            <objects>
+                <viewController id="01J-lp-oVM" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
+                        <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
+                        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <animations/>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+                    </view>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="53" y="375"/>
+        </scene>
+    </scenes>
+</document>

+ 93 - 0
Carthage/Checkouts/PDFGenerator/Demo/Base.lproj/Main.storyboard

@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
+    </dependencies>
+    <scenes>
+        <!--View Controller-->
+        <scene sceneID="tne-QT-ifu">
+            <objects>
+                <viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
+                        <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
+                        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Q1C-IW-pDs">
+                                <rect key="frame" x="253" y="30" width="95" height="30"/>
+                                <state key="normal" title="Sample PDF 1"/>
+                                <connections>
+                                    <action selector="generateSamplePDFFromViews:" destination="BYZ-38-t0r" eventType="touchUpInside" id="AXR-4y-Mdb"/>
+                                </connections>
+                            </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="otR-Ne-HCB">
+                                <rect key="frame" x="252" y="92" width="97" height="30"/>
+                                <state key="normal" title="Sample PDF 2"/>
+                                <connections>
+                                    <action selector="generateSamplePDFFromImages:" destination="BYZ-38-t0r" eventType="touchUpInside" id="eLZ-nd-qpJ"/>
+                                </connections>
+                            </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PqT-gX-IbR">
+                                <rect key="frame" x="252" y="154" width="97" height="30"/>
+                                <state key="normal" title="Sample PDF 3"/>
+                                <connections>
+                                    <action selector="generateSamplePDFFromImagePaths:" destination="BYZ-38-t0r" eventType="touchUpInside" id="waY-kW-WyO"/>
+                                </connections>
+                            </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DkP-FK-dJj">
+                                <rect key="frame" x="252" y="216" width="97" height="30"/>
+                                <state key="normal" title="Sample PDF 4"/>
+                                <connections>
+                                    <action selector="generateSamplePDFFromPages:" destination="BYZ-38-t0r" eventType="touchUpInside" id="gHy-GB-ZKw"/>
+                                </connections>
+                            </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8t7-aQ-m9b">
+                                <rect key="frame" x="240" y="278" width="121" height="30"/>
+                                <state key="normal" title="TableViewSample"/>
+                                <connections>
+                                    <action selector="goSampleTableView:" destination="BYZ-38-t0r" eventType="touchUpInside" id="zwK-1N-YJz"/>
+                                </connections>
+                            </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vuR-cn-rxB">
+                                <rect key="frame" x="243" y="340" width="115" height="30"/>
+                                <state key="normal" title="WebViewSample"/>
+                                <connections>
+                                    <action selector="goSampleWebView:" destination="BYZ-38-t0r" eventType="touchUpInside" id="jsT-Zc-itd"/>
+                                </connections>
+                            </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hOG-oa-gjr">
+                                <rect key="frame" x="264" y="402" width="72" height="30"/>
+                                <state key="normal" title="ScrollView"/>
+                                <connections>
+                                    <action selector="generatePDFFromStackedScrollView:" destination="BYZ-38-t0r" eventType="touchUpInside" id="vK5-hw-xGC"/>
+                                </connections>
+                            </button>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+                        <constraints>
+                            <constraint firstItem="vuR-cn-rxB" firstAttribute="top" secondItem="8t7-aQ-m9b" secondAttribute="bottom" constant="32" id="Del-tz-jeP"/>
+                            <constraint firstItem="vuR-cn-rxB" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="H14-KM-hNQ"/>
+                            <constraint firstItem="PqT-gX-IbR" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="JPb-m4-YaX"/>
+                            <constraint firstItem="PqT-gX-IbR" firstAttribute="top" secondItem="otR-Ne-HCB" secondAttribute="bottom" constant="32" id="MKa-53-SIW"/>
+                            <constraint firstItem="8t7-aQ-m9b" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="McM-qz-NmT"/>
+                            <constraint firstItem="8t7-aQ-m9b" firstAttribute="top" secondItem="DkP-FK-dJj" secondAttribute="bottom" constant="32" id="RRF-nG-835"/>
+                            <constraint firstItem="DkP-FK-dJj" firstAttribute="top" secondItem="PqT-gX-IbR" secondAttribute="bottom" constant="32" id="ZIO-0v-UiU"/>
+                            <constraint firstItem="Q1C-IW-pDs" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="ZIq-t1-VH4"/>
+                            <constraint firstItem="otR-Ne-HCB" firstAttribute="top" secondItem="Q1C-IW-pDs" secondAttribute="bottom" constant="32" id="aJW-pe-WkJ"/>
+                            <constraint firstItem="hOG-oa-gjr" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="f9b-AI-0VP"/>
+                            <constraint firstItem="hOG-oa-gjr" firstAttribute="top" secondItem="vuR-cn-rxB" secondAttribute="bottom" constant="32" id="hHB-9e-HzI"/>
+                            <constraint firstItem="Q1C-IW-pDs" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" constant="30" id="kWe-bM-iZz"/>
+                            <constraint firstItem="DkP-FK-dJj" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="uar-c7-3if"/>
+                            <constraint firstItem="otR-Ne-HCB" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="xRr-0u-gc1"/>
+                        </constraints>
+                    </view>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
+            </objects>
+        </scene>
+    </scenes>
+</document>

+ 45 - 0
Carthage/Checkouts/PDFGenerator/Demo/Info.plist

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>$(EXECUTABLE_NAME)</string>
+	<key>CFBundleIdentifier</key>
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>$(PRODUCT_NAME)</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>1</string>
+	<key>LSRequiresIPhoneOS</key>
+	<true/>
+	<key>UILaunchStoryboardName</key>
+	<string>LaunchScreen</string>
+	<key>UIMainStoryboardFile</key>
+	<string>Main</string>
+	<key>UIRequiredDeviceCapabilities</key>
+	<array>
+		<string>armv7</string>
+	</array>
+	<key>UISupportedInterfaceOrientations</key>
+	<array>
+		<string>UIInterfaceOrientationPortrait</string>
+		<string>UIInterfaceOrientationLandscapeLeft</string>
+		<string>UIInterfaceOrientationLandscapeRight</string>
+	</array>
+	<key>NSAppTransportSecurity</key>
+	<dict>
+		<key>NSAllowsArbitraryLoads</key>
+		<true/>
+	</dict>
+</dict>
+</plist>

+ 93 - 0
Carthage/Checkouts/PDFGenerator/Demo/PDFOutput.storyboard

@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="xO5-sL-uMu">
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
+    </dependencies>
+    <scenes>
+        <!--Output View Controller-->
+        <scene sceneID="QUL-cJ-At4">
+            <objects>
+                <viewController id="xO5-sL-uMu" customClass="PDFOutputViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="bHE-tX-FHo"/>
+                        <viewControllerLayoutGuide type="bottom" id="VPv-mx-pqZ"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="aat-qp-fRI">
+                        <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qs4-td-9bM">
+                                <rect key="frame" x="60" y="184" width="200" height="200"/>
+                                <subviews>
+                                    <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7Il-vD-9Vg">
+                                        <rect key="frame" x="0.0" y="0.0" width="200" height="200"/>
+                                        <subviews>
+                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="64d-dD-dXA">
+                                                <rect key="frame" x="0.0" y="200" width="400" height="200"/>
+                                                <color key="backgroundColor" red="0.2901960784" green="0.56470588239999997" blue="0.8862745098" alpha="1" colorSpace="calibratedRGB"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="height" constant="200" id="jcc-L4-6aU"/>
+                                                    <constraint firstAttribute="width" constant="400" id="zX4-NT-dLb"/>
+                                                </constraints>
+                                            </view>
+                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4Rw-OV-Ohh">
+                                                <rect key="frame" x="0.0" y="0.0" width="400" height="200"/>
+                                                <color key="backgroundColor" red="1" green="0.1169351243" blue="0.1518404542" alpha="1" colorSpace="calibratedRGB"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="width" constant="400" id="1M6-p7-xb5"/>
+                                                    <constraint firstAttribute="height" constant="200" id="NPW-P0-pNk"/>
+                                                </constraints>
+                                            </view>
+                                        </subviews>
+                                        <constraints>
+                                            <constraint firstItem="64d-dD-dXA" firstAttribute="leading" secondItem="7Il-vD-9Vg" secondAttribute="leading" id="4II-B2-VLa"/>
+                                            <constraint firstItem="4Rw-OV-Ohh" firstAttribute="top" secondItem="7Il-vD-9Vg" secondAttribute="top" id="6Nm-4h-4FT"/>
+                                            <constraint firstItem="64d-dD-dXA" firstAttribute="top" secondItem="4Rw-OV-Ohh" secondAttribute="bottom" id="L7c-jj-cKN"/>
+                                            <constraint firstItem="4Rw-OV-Ohh" firstAttribute="leading" secondItem="7Il-vD-9Vg" secondAttribute="leading" id="LPD-06-Puu"/>
+                                            <constraint firstAttribute="trailing" secondItem="64d-dD-dXA" secondAttribute="trailing" id="fcj-ni-yss"/>
+                                            <constraint firstAttribute="bottom" secondItem="64d-dD-dXA" secondAttribute="bottom" id="kjx-Gy-CYb"/>
+                                            <constraint firstAttribute="trailing" secondItem="4Rw-OV-Ohh" secondAttribute="trailing" id="kks-Nr-q8c"/>
+                                        </constraints>
+                                    </scrollView>
+                                </subviews>
+                                <color key="backgroundColor" red="0.52317320609999995" green="1" blue="0.4941985679" alpha="1" colorSpace="calibratedRGB"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="200" id="Ttv-cS-7Kl"/>
+                                    <constraint firstAttribute="height" constant="200" id="VBH-Cd-Ddq"/>
+                                    <constraint firstAttribute="trailing" secondItem="7Il-vD-9Vg" secondAttribute="trailing" id="W2a-5X-smO"/>
+                                    <constraint firstItem="7Il-vD-9Vg" firstAttribute="top" secondItem="qs4-td-9bM" secondAttribute="top" id="e5m-Vu-YTu"/>
+                                    <constraint firstAttribute="bottom" secondItem="7Il-vD-9Vg" secondAttribute="bottom" id="hBX-30-0Ty"/>
+                                    <constraint firstItem="7Il-vD-9Vg" firstAttribute="leading" secondItem="qs4-td-9bM" secondAttribute="leading" id="uaH-1a-GKu"/>
+                                </constraints>
+                            </view>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wlC-iH-cGZ">
+                                <rect key="frame" x="138" y="414" width="45" height="30"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="45" id="jfN-bx-QRn"/>
+                                    <constraint firstAttribute="height" constant="30" id="vnB-Fu-Upz"/>
+                                </constraints>
+                                <state key="normal" title="render"/>
+                                <connections>
+                                    <action selector="render:" destination="xO5-sL-uMu" eventType="touchUpInside" id="HrA-DD-eVs"/>
+                                </connections>
+                            </button>
+                        </subviews>
+                        <color key="backgroundColor" red="0.85676812830000004" green="0.54246098330000003" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                        <constraints>
+                            <constraint firstItem="qs4-td-9bM" firstAttribute="centerY" secondItem="aat-qp-fRI" secondAttribute="centerY" id="FJc-og-aCK"/>
+                            <constraint firstItem="qs4-td-9bM" firstAttribute="centerX" secondItem="aat-qp-fRI" secondAttribute="centerX" id="GsK-zG-Pwz"/>
+                            <constraint firstItem="wlC-iH-cGZ" firstAttribute="top" secondItem="qs4-td-9bM" secondAttribute="bottom" constant="30" id="Rzl-DT-9MZ"/>
+                            <constraint firstItem="wlC-iH-cGZ" firstAttribute="centerX" secondItem="aat-qp-fRI" secondAttribute="centerX" id="t73-Kh-4HO"/>
+                        </constraints>
+                    </view>
+                    <connections>
+                        <outlet property="scrollView" destination="7Il-vD-9Vg" id="FG9-or-t6n"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="KMa-Wz-Amq" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="321.06666666666666" y="440.19999999999999"/>
+        </scene>
+    </scenes>
+</document>

+ 50 - 0
Carthage/Checkouts/PDFGenerator/Demo/PDFOutputViewController.swift

@@ -0,0 +1,50 @@
+//
+//  PDFOutputViewController.swift
+//  PDFGenerator
+//
+//  Created by Suguru Kishimoto on 9/7/16.
+//
+//
+
+import UIKit
+import PDFGenerator
+
+class PDFOutputViewController: UIViewController {
+
+    @IBOutlet fileprivate weak var scrollView: UIScrollView!
+    override func viewDidLoad() {
+        super.viewDidLoad()
+
+        // Do any additional setup after loading the view.
+    }
+
+    override func didReceiveMemoryWarning() {
+        super.didReceiveMemoryWarning()
+        // Dispose of any resources that can be recreated.
+    }
+    
+    @IBAction func render(_: UIButton) {
+        let dst = NSHomeDirectory() + "/test.pdf"
+        try! PDFGenerator.generate(self.scrollView, to: dst)
+        openPDFViewer(dst)
+    }
+    
+    fileprivate func openPDFViewer(_ pdfPath: String) {
+        let url = URL(fileURLWithPath: pdfPath)
+        let storyboard = UIStoryboard(name: "PDFPreviewVC", bundle: nil)
+        let vc = storyboard.instantiateInitialViewController() as! PDFPreviewVC
+        vc.setupWithURL(url)
+        present(vc, animated: true, completion: nil)
+    }
+
+    /*
+    // MARK: - Navigation
+
+    // In a storyboard-based application, you will often want to do a little preparation before navigation
+    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
+        // Get the new view controller using segue.destinationViewController.
+        // Pass the selected object to the new view controller.
+    }
+    */
+
+}

+ 67 - 0
Carthage/Checkouts/PDFGenerator/Demo/PDFPreviewVC.storyboard

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="7Hn-bD-ujW">
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
+    </dependencies>
+    <scenes>
+        <!--PreviewVC-->
+        <scene sceneID="BoV-cP-0sY">
+            <objects>
+                <viewController id="7Hn-bD-ujW" customClass="PDFPreviewVC" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="5yI-p4-Eij"/>
+                        <viewControllerLayoutGuide type="bottom" id="hAG-XP-Aaz"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="YGd-n0-0Xl">
+                        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PdX-6V-CI9">
+                                <rect key="frame" x="0.0" y="0.0" width="600" height="64"/>
+                                <subviews>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Mrg-Ib-dGc">
+                                        <rect key="frame" x="16" y="27" width="60" height="30"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="30" id="XeW-vz-XoI"/>
+                                            <constraint firstAttribute="width" constant="60" id="mBz-Nb-mFc"/>
+                                        </constraints>
+                                        <state key="normal" title="Close"/>
+                                        <connections>
+                                            <action selector="close:" destination="7Hn-bD-ujW" eventType="touchUpInside" id="nNU-hg-ofw"/>
+                                        </connections>
+                                    </button>
+                                </subviews>
+                                <color key="backgroundColor" red="0.93122661110000005" green="0.93119871620000005" blue="0.9312145114" alpha="1" colorSpace="calibratedRGB"/>
+                                <constraints>
+                                    <constraint firstItem="Mrg-Ib-dGc" firstAttribute="centerY" secondItem="PdX-6V-CI9" secondAttribute="centerY" constant="10" id="7La-5g-lE7"/>
+                                    <constraint firstItem="Mrg-Ib-dGc" firstAttribute="leading" secondItem="PdX-6V-CI9" secondAttribute="leading" constant="16" id="Ypn-6q-kgk"/>
+                                    <constraint firstAttribute="height" constant="64" id="fLW-s8-iTd"/>
+                                </constraints>
+                            </view>
+                            <webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Igd-XZ-bT9">
+                                <rect key="frame" x="0.0" y="64" width="600" height="536"/>
+                                <color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="deviceRGB"/>
+                            </webView>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                        <constraints>
+                            <constraint firstItem="PdX-6V-CI9" firstAttribute="top" secondItem="YGd-n0-0Xl" secondAttribute="top" id="5fT-BR-KEd"/>
+                            <constraint firstItem="Igd-XZ-bT9" firstAttribute="leading" secondItem="YGd-n0-0Xl" secondAttribute="leading" id="AHt-ne-34F"/>
+                            <constraint firstAttribute="trailing" secondItem="Igd-XZ-bT9" secondAttribute="trailing" id="Fbl-js-706"/>
+                            <constraint firstItem="Igd-XZ-bT9" firstAttribute="top" secondItem="PdX-6V-CI9" secondAttribute="bottom" id="L1K-sb-l9K"/>
+                            <constraint firstAttribute="trailing" secondItem="PdX-6V-CI9" secondAttribute="trailing" id="NDT-Na-kEi"/>
+                            <constraint firstItem="PdX-6V-CI9" firstAttribute="leading" secondItem="YGd-n0-0Xl" secondAttribute="leading" id="RhG-Ek-Gxm"/>
+                            <constraint firstAttribute="bottom" secondItem="Igd-XZ-bT9" secondAttribute="bottom" id="dVl-ig-xU2"/>
+                        </constraints>
+                    </view>
+                    <connections>
+                        <outlet property="webView" destination="Igd-XZ-bT9" id="ID4-Bg-EVs"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="1cM-d1-vR2" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="684" y="212"/>
+        </scene>
+    </scenes>
+</document>

+ 37 - 0
Carthage/Checkouts/PDFGenerator/Demo/PDFPreviewVC.swift

@@ -0,0 +1,37 @@
+//
+//  PDFPreviewVC.swift
+//  PDFGenerator
+//
+//  Created by Suguru Kishimoto on 2016/02/06.
+//
+//
+
+import UIKit
+
+class PDFPreviewVC: UIViewController {
+    
+    @IBOutlet fileprivate weak var webView: UIWebView!
+    var url: URL!
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        let req = NSMutableURLRequest(url: url)
+        req.timeoutInterval = 60.0
+        req.cachePolicy = .reloadIgnoringLocalAndRemoteCacheData
+
+        webView.scalesPageToFit = true
+        webView.loadRequest(req as URLRequest)
+    }
+
+    override func didReceiveMemoryWarning() {
+        super.didReceiveMemoryWarning()
+    }
+    
+    @objc @IBAction fileprivate func close(_ sender: AnyObject!) {
+        dismiss(animated: true, completion: nil)
+    }
+    
+    func setupWithURL(_ url: URL) {
+        self.url = url
+    }
+
+}

+ 36 - 0
Carthage/Checkouts/PDFGenerator/Demo/PDFViewController.storyboard

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="lA4-ro-Ofe">
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
+    </dependencies>
+    <scenes>
+        <!--View Controller-->
+        <scene sceneID="cBO-i2-gze">
+            <objects>
+                <viewController id="lA4-ro-Ofe" customClass="PDFViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="Rhx-Xm-zHc"/>
+                        <viewControllerLayoutGuide type="bottom" id="9tD-Eb-9d5"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="xJ6-2m-mYq">
+                        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <webView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7LL-RX-fgX">
+                                <rect key="frame" x="180" y="193" width="240" height="128"/>
+                                <color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="deviceRGB"/>
+                            </webView>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                    </view>
+                    <connections>
+                        <outlet property="webView" destination="7LL-RX-fgX" id="wZ3-bf-eza"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="6ww-PI-g02" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="635" y="386"/>
+        </scene>
+    </scenes>
+</document>

+ 29 - 0
Carthage/Checkouts/PDFGenerator/Demo/PDFViewController.swift

@@ -0,0 +1,29 @@
+//
+//  PDFViewController.swift
+//  PDFMaker
+//
+//  Created by Suguru Kishimoto on 2016/02/05.
+//
+//
+
+import UIKit
+
+class PDFViewController: UIViewController {
+    
+    @IBOutlet private weak var webView: UIWebView!
+    @IBOutlet private weak var closeButton: UIButton!
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+    }
+
+    override func didReceiveMemoryWarning() {
+        super.didReceiveMemoryWarning()
+    }
+    
+    func setupWithURL(url: NSURL) {
+        let req = NSURLRequest(URL: url, cachePolicy: .ReloadIgnoringLocalAndRemoteCacheData, timeoutInterval: 60)
+        webView.loadRequest(req)
+    }
+    
+}

+ 23 - 0
Carthage/Checkouts/PDFGenerator/Demo/SampleTableViewCell.swift

@@ -0,0 +1,23 @@
+//
+//  SampleTableViewCell.swift
+//  PDFGenerator
+//
+//  Created by Suguru Kishimoto on 2016/02/27.
+//
+//
+
+import UIKit
+
+class SampleTableViewCell: UITableViewCell {
+
+    @IBOutlet weak var leftLabel: UILabel!
+    @IBOutlet weak var rightLabel: UILabel!
+    override func awakeFromNib() {
+        super.awakeFromNib()
+    }
+
+    override func setSelected(_ selected: Bool, animated: Bool) {
+        super.setSelected(selected, animated: animated)
+    }
+
+}

+ 70 - 0
Carthage/Checkouts/PDFGenerator/Demo/SampleTableViewController.storyboard

@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="4wT-3U-j3F">
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
+        <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
+    </dependencies>
+    <scenes>
+        <!--Sample Table View Controller-->
+        <scene sceneID="TKp-H0-I3P">
+            <objects>
+                <tableViewController id="4wT-3U-j3F" customClass="SampleTableViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
+                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="Gfi-OA-RfQ">
+                        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                        <prototypes>
+                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="hRd-LY-XjG" customClass="SampleTableViewCell" customModule="Demo" customModuleProvider="target">
+                                <rect key="frame" x="0.0" y="28" width="600" height="44"/>
+                                <autoresizingMask key="autoresizingMask"/>
+                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hRd-LY-XjG" id="cFY-ba-p1v">
+                                    <rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
+                                    <autoresizingMask key="autoresizingMask"/>
+                                    <subviews>
+                                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BHf-3f-fHF">
+                                            <rect key="frame" x="16" y="11" width="200" height="21"/>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="21" id="3lx-Yu-VcB"/>
+                                                <constraint firstAttribute="width" constant="200" id="yTE-Gm-4vg"/>
+                                            </constraints>
+                                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                            <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+                                            <nil key="highlightedColor"/>
+                                        </label>
+                                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SYO-87-FkQ">
+                                            <rect key="frame" x="384" y="11" width="200" height="21"/>
+                                            <constraints>
+                                                <constraint firstAttribute="width" constant="200" id="EC5-Ob-cwi"/>
+                                                <constraint firstAttribute="height" constant="21" id="Ki8-nY-Zw3"/>
+                                            </constraints>
+                                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                            <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+                                            <nil key="highlightedColor"/>
+                                        </label>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstItem="BHf-3f-fHF" firstAttribute="leading" secondItem="cFY-ba-p1v" secondAttribute="leadingMargin" constant="8" id="OWc-d2-3Kc"/>
+                                        <constraint firstItem="BHf-3f-fHF" firstAttribute="centerY" secondItem="cFY-ba-p1v" secondAttribute="centerY" id="apx-WT-hCh"/>
+                                        <constraint firstItem="SYO-87-FkQ" firstAttribute="centerY" secondItem="cFY-ba-p1v" secondAttribute="centerY" id="ix7-6X-G5F"/>
+                                        <constraint firstAttribute="trailingMargin" secondItem="SYO-87-FkQ" secondAttribute="trailing" constant="8" id="mKQ-oZ-wJR"/>
+                                    </constraints>
+                                </tableViewCellContentView>
+                                <connections>
+                                    <outlet property="leftLabel" destination="BHf-3f-fHF" id="DrU-nI-LuS"/>
+                                    <outlet property="rightLabel" destination="SYO-87-FkQ" id="cDo-TB-Tml"/>
+                                </connections>
+                            </tableViewCell>
+                        </prototypes>
+                        <connections>
+                            <outlet property="dataSource" destination="4wT-3U-j3F" id="4rD-nT-RaB"/>
+                            <outlet property="delegate" destination="4wT-3U-j3F" id="Zpt-pd-xjw"/>
+                        </connections>
+                    </tableView>
+                </tableViewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="gDh-v1-sOp" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="625" y="418"/>
+        </scene>
+    </scenes>
+</document>

+ 112 - 0
Carthage/Checkouts/PDFGenerator/Demo/SampleTableViewController.swift

@@ -0,0 +1,112 @@
+//
+//  SampleTableViewController.swift
+//  PDFGenerator
+//
+//  Created by Suguru Kishimoto on 2016/02/27.
+//
+//
+
+import UIKit
+import PDFGenerator
+
+class SampleTableViewController: UITableViewController {
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        self.tableView.contentInset = UIEdgeInsets(top: 100.0, left: 0.0, bottom: 0.0, right: 0.0)
+    }
+
+    override func didReceiveMemoryWarning() {
+        super.didReceiveMemoryWarning()
+    }
+    
+    @objc fileprivate func generatePDF() {
+        do {
+            let dst = NSHomeDirectory() + "/sample_tblview.pdf"
+            try PDFGenerator.generate(self.tableView, to: dst)
+            openPDFViewer(dst)
+        } catch let error {
+            print(error)
+        }
+        
+    }
+
+    fileprivate func openPDFViewer(_ pdfPath: String) {
+        let url = URL(fileURLWithPath: pdfPath)
+        let storyboard = UIStoryboard(name: "PDFPreviewVC", bundle: nil)
+        let vc = storyboard.instantiateInitialViewController() as! PDFPreviewVC
+        vc.setupWithURL(url)
+        present(vc, animated: true, completion: nil)
+    }
+
+    // MARK: - Table view data source
+
+    override func numberOfSections(in tableView: UITableView) -> Int {
+        return 3
+    }
+
+    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return 10
+    }
+
+    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! SampleTableViewCell
+        cell.leftLabel.text = "\((indexPath as NSIndexPath).section)-\((indexPath as NSIndexPath).row)cell"
+        cell.rightLabel.text = "sample"
+        return cell
+    }
+    
+    override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
+        return "section\(section)"
+    }
+    
+    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        generatePDF()
+    }
+    
+    /*
+    // Override to support conditional editing of the table view.
+    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
+        // Return false if you do not want the specified item to be editable.
+        return true
+    }
+    */
+
+    /*
+    // Override to support editing the table view.
+    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
+        if editingStyle == .Delete {
+            // Delete the row from the data source
+            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
+        } else if editingStyle == .Insert {
+            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
+        }    
+    }
+    */
+
+    /*
+    // Override to support rearranging the table view.
+    override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
+
+    }
+    */
+
+    /*
+    // Override to support conditional rearranging of the table view.
+    override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
+        // Return false if you do not want the item to be re-orderable.
+        return true
+    }
+    */
+
+    /*
+    // MARK: - Navigation
+
+    // In a storyboard-based application, you will often want to do a little preparation before navigation
+    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
+        // Get the new view controller using segue.destinationViewController.
+        // Pass the selected object to the new view controller.
+    }
+    */
+
+}

+ 151 - 0
Carthage/Checkouts/PDFGenerator/Demo/ViewController.swift

@@ -0,0 +1,151 @@
+//
+//  ViewController.swift
+//  Demo
+//
+//  Created by Suguru Kishimoto on 2016/02/04.
+//
+//
+
+import UIKit
+import PDFGenerator
+
+class ViewController: UIViewController {
+    
+    fileprivate var outputAsData: Bool = false
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        // Do any additional setup after loading the view, typically from a nib.
+    }
+
+    override func didReceiveMemoryWarning() {
+        super.didReceiveMemoryWarning()
+        // Dispose of any resources that can be recreated.
+    }
+
+    fileprivate func getImagePath(_ number: Int) -> String {
+        return Bundle.main.path(forResource: "sample_\(number)", ofType: "jpg")!
+    }
+    
+    fileprivate func getDestinationPath(_ number: Int) -> String {
+        return NSHomeDirectory() + "/sample\(number).pdf"
+    }
+    
+    @objc @IBAction fileprivate func generateSamplePDFFromViews(_ sender: AnyObject?) {
+        let v1 = UIScrollView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
+        let v2 = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 200))
+        let v3 = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 200))
+        v1.backgroundColor = UIColor.red
+        v1.contentSize = CGSize(width: 100, height: 100)
+        v2.backgroundColor = UIColor.green
+        v3.backgroundColor = UIColor.blue
+        
+        do {
+            let dst = getDestinationPath(1)
+            if outputAsData {
+                let data = try PDFGenerator.generated(by: [v1, v2, v3])
+                try data.write(to: URL(fileURLWithPath: dst))
+            } else {
+                try PDFGenerator.generate([v1, v2, v3], to: dst)
+            }
+            openPDFViewer(dst)
+        } catch (let e) {
+            print(e)
+        }
+    }
+    
+    @objc @IBAction fileprivate func generateSamplePDFFromImages(_ sender: AnyObject?) {
+        let dst = getDestinationPath(2)
+        autoreleasepool {
+            do {
+                var images = [UIImage]()
+                (0..<3).forEach {
+                    images.append(UIImage(contentsOfFile: getImagePath($0))!)
+                }
+                if outputAsData {
+                    let data = try PDFGenerator.generated(by: images)
+                    try data.write(to: URL(fileURLWithPath: dst))
+                } else {
+                    try PDFGenerator.generate(images, to: dst, dpi: .custom(144), password: "123456")
+                }
+                openPDFViewer(dst)
+            } catch (let e) {
+                print(e)
+            }
+        }
+    }
+    
+    @objc @IBAction fileprivate func generateSamplePDFFromImagePaths(_ sender: AnyObject?) {
+        do {
+            let dst = getDestinationPath(3)
+            var imagePaths = [String]()
+            (3..<6).forEach {
+                imagePaths.append(getImagePath($0))
+            }
+            if outputAsData {
+                let data = try PDFGenerator.generated(by: imagePaths)
+                try data.write(to: URL(fileURLWithPath: dst))
+            } else {
+                try PDFGenerator.generate(imagePaths, to: dst)
+            }
+            openPDFViewer(dst)
+        } catch (let e) {
+            print(e)
+        }
+    }
+    
+    @objc @IBAction fileprivate func generateSamplePDFFromPages(_ sender: AnyObject?) {
+        let v1 = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
+        v1.backgroundColor = UIColor.red
+        let v2 = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 200))
+        v2.backgroundColor = UIColor.green
+        
+        let page1 = PDFPage.view(v1)
+        let page2 = PDFPage.view(v2)
+        let page3 = PDFPage.whitePage(CGSize(width: 200, height: 100))
+        let page4 = PDFPage.image(UIImage(contentsOfFile: getImagePath(1))!)
+        let page5 = PDFPage.imagePath(getImagePath(2))
+        let pages = [page1, page2, page3, page4, page5]
+        do {
+            let dst = getDestinationPath(3)
+            if outputAsData {
+                let data = try PDFGenerator.generated(by: pages)
+                try data.write(to: URL(fileURLWithPath: dst))
+            } else {
+                try PDFGenerator.generate(pages, to: dst)
+            }
+            openPDFViewer(dst)
+        } catch (let e) {
+            print(e)
+
+        }
+    }
+    
+    @objc @IBAction fileprivate func generatePDFFromStackedScrollView(_: AnyObject?) {
+        let storyboard = UIStoryboard(name: "PDFOutput", bundle: nil)
+        let vc = storyboard.instantiateInitialViewController()!
+        
+        present(vc, animated: true, completion: nil)
+    }
+
+    fileprivate func openPDFViewer(_ pdfPath: String) {
+        let url = URL(fileURLWithPath: pdfPath)        
+        let storyboard = UIStoryboard(name: "PDFPreviewVC", bundle: nil)
+        let vc = storyboard.instantiateInitialViewController() as! PDFPreviewVC
+        vc.setupWithURL(url)
+        present(vc, animated: true, completion: nil)
+    }
+
+    @objc @IBAction fileprivate func goSampleTableView(_ sender: AnyObject?) {
+        let storyboard = UIStoryboard(name: "SampleTableViewController", bundle: nil)
+        let vc = storyboard.instantiateInitialViewController() as! SampleTableViewController
+        present(vc, animated: true, completion: nil)
+    }
+    
+    @objc @IBAction fileprivate func goSampleWebView(_ sender: AnyObject?) {
+        let storyboard = UIStoryboard(name: "WebViewController", bundle: nil)
+        let vc = storyboard.instantiateInitialViewController() as! WebViewController
+        present(vc, animated: true, completion: nil)
+    }
+
+}

+ 57 - 0
Carthage/Checkouts/PDFGenerator/Demo/WebViewController.storyboard

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="agr-Bd-01h">
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
+    </dependencies>
+    <scenes>
+        <!--Web View Controller-->
+        <scene sceneID="xDk-0N-TTV">
+            <objects>
+                <viewController id="agr-Bd-01h" customClass="WebViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="tFx-VQ-KEU"/>
+                        <viewControllerLayoutGuide type="bottom" id="yiC-n7-0o7"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="IRc-XT-O1w">
+                        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VC0-fG-sSg">
+                                <rect key="frame" x="0.0" y="20" width="600" height="200"/>
+                                <color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="deviceRGB"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="200" id="BaV-Vk-89A"/>
+                                </constraints>
+                            </webView>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GnF-lf-UMf">
+                                <rect key="frame" x="285" y="250" width="30" height="30"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="30" id="fco-gS-WH1"/>
+                                    <constraint firstAttribute="height" constant="30" id="tDp-3p-Egp"/>
+                                </constraints>
+                                <state key="normal" title="PDF"/>
+                                <connections>
+                                    <action selector="generatePDF" destination="agr-Bd-01h" eventType="touchUpInside" id="1Dr-rA-1tr"/>
+                                </connections>
+                            </button>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                        <constraints>
+                            <constraint firstItem="GnF-lf-UMf" firstAttribute="centerX" secondItem="IRc-XT-O1w" secondAttribute="centerX" id="EEL-dG-gHB"/>
+                            <constraint firstItem="VC0-fG-sSg" firstAttribute="leading" secondItem="IRc-XT-O1w" secondAttribute="leading" id="JFA-ge-bAo"/>
+                            <constraint firstItem="GnF-lf-UMf" firstAttribute="top" secondItem="VC0-fG-sSg" secondAttribute="bottom" constant="30" id="Jxb-tE-jJ6"/>
+                            <constraint firstAttribute="trailing" secondItem="VC0-fG-sSg" secondAttribute="trailing" id="TPP-ws-uqx"/>
+                            <constraint firstItem="VC0-fG-sSg" firstAttribute="top" secondItem="tFx-VQ-KEU" secondAttribute="bottom" id="gls-O5-HeG"/>
+                        </constraints>
+                    </view>
+                    <connections>
+                        <outlet property="webView" destination="VC0-fG-sSg" id="FN0-YH-6N8"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="tD9-QV-HgR" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="762" y="285"/>
+        </scene>
+    </scenes>
+</document>

+ 56 - 0
Carthage/Checkouts/PDFGenerator/Demo/WebViewController.swift

@@ -0,0 +1,56 @@
+//
+//  WebViewController.swift
+//  PDFGenerator
+//
+//  Created by Suguru Kishimoto on 2016/03/23.
+//
+//
+
+import UIKit
+import WebKit
+import PDFGenerator
+
+class WebViewController: UIViewController {
+
+    @IBOutlet fileprivate weak var webView: UIWebView!
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        let req = NSMutableURLRequest(url: URL(string: "http://www.yahoo.co.jp")!, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: 60)
+        webView.loadRequest(req as URLRequest)
+    }
+
+    override func didReceiveMemoryWarning() {
+        super.didReceiveMemoryWarning()
+    }
+    
+    @IBAction func generatePDF() {
+        do {
+            let dst = NSHomeDirectory() + "/sample_tblview.pdf"
+            try PDFGenerator.generate(webView, to: dst)
+            openPDFViewer(dst)
+        } catch let error {
+            print(error)
+        }
+        
+    }
+
+    fileprivate func openPDFViewer(_ pdfPath: String) {
+        let url = URL(fileURLWithPath: pdfPath)
+        let storyboard = UIStoryboard(name: "PDFPreviewVC", bundle: nil)
+        let vc = storyboard.instantiateInitialViewController() as! PDFPreviewVC
+        vc.setupWithURL(url)
+        present(vc, animated: true, completion: nil)
+    }
+
+    /*
+    // MARK: - Navigation
+
+    // In a storyboard-based application, you will often want to do a little preparation before navigation
+    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
+        // Get the new view controller using segue.destinationViewController.
+        // Pass the selected object to the new view controller.
+    }
+    */
+
+}

TEMPAT SAMPAH
Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_0.jpg


TEMPAT SAMPAH
Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_1.jpg


TEMPAT SAMPAH
Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_2.jpg


TEMPAT SAMPAH
Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_3.jpg


TEMPAT SAMPAH
Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_4.jpg


TEMPAT SAMPAH
Carthage/Checkouts/PDFGenerator/Demo/sample_images/sample_5.jpg


+ 21 - 0
Carthage/Checkouts/PDFGenerator/LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Suguru Kishimoto
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 14 - 0
Carthage/Checkouts/PDFGenerator/PDFGenerator.podspec

@@ -0,0 +1,14 @@
+Pod::Spec.new do |s|
+  s.name             = "PDFGenerator"
+  s.version          = "2.1"
+  s.summary          = "A simple PDF generator."
+  s.homepage         = "https://github.com/sgr-ksmt/PDFGenerator"
+  # s.screenshots     = ""
+  s.license          = 'MIT'
+  s.author           = { "Suguru Kishimoto" => "melodydance.k.s@gmail.com" }
+  s.source           = { :git => "https://github.com/sgr-ksmt/PDFGenerator.git", :tag => s.version.to_s }
+  s.platform         = :ios, '8.0'
+  s.requires_arc     = true
+  s.source_files     = "PDFGenerator/**/*"
+  s.frameworks   = 'WebKit'
+end

+ 0 - 0
Libraries external/PDFGenerator/DPIType.swift → Carthage/Checkouts/PDFGenerator/PDFGenerator/DPIType.swift


+ 0 - 0
Libraries external/PDFGenerator/FilePathConvertible.swift → Carthage/Checkouts/PDFGenerator/PDFGenerator/FilePathConvertible.swift


+ 26 - 0
Carthage/Checkouts/PDFGenerator/PDFGenerator/Info.plist

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>$(EXECUTABLE_NAME)</string>
+	<key>CFBundleIdentifier</key>
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>$(PRODUCT_NAME)</string>
+	<key>CFBundlePackageType</key>
+	<string>FMWK</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>$(CURRENT_PROJECT_VERSION)</string>
+	<key>NSPrincipalClass</key>
+	<string></string>
+</dict>
+</plist>

+ 0 - 0
Libraries external/PDFGenerator/PDFGenerateError.swift → Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFGenerateError.swift


+ 0 - 0
Libraries external/PDFGenerator/PDFGenerator.h → Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFGenerator.h


+ 0 - 0
Libraries external/PDFGenerator/PDFGenerator.swift → Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFGenerator.swift


+ 0 - 0
Libraries external/PDFGenerator/PDFPage.swift → Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFPage.swift


+ 0 - 0
Libraries external/PDFGenerator/PDFPageRenderable.swift → Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFPageRenderable.swift


+ 4 - 4
Libraries external/PDFGenerator/PDFPassword.swift → Carthage/Checkouts/PDFGenerator/PDFGenerator/PDFPassword.swift

@@ -39,15 +39,15 @@ public struct PDFPassword {
         guard userPassword.canBeConverted(to: String.Encoding.ascii) else {
             throw PDFGenerateError.invalidPassword(userPassword)
         }
-        guard userPassword.count <= type(of: self).PasswordLengthMax else {
-            throw PDFGenerateError.tooLongPassword(userPassword.count)
+        guard userPassword.characters.count <= type(of: self).PasswordLengthMax else {
+            throw PDFGenerateError.tooLongPassword(userPassword.characters.count)
         }
         
         guard ownerPassword.canBeConverted(to: String.Encoding.ascii) else {
             throw PDFGenerateError.invalidPassword(ownerPassword)
         }
-        guard ownerPassword.count <= type(of: self).PasswordLengthMax else {
-            throw PDFGenerateError.tooLongPassword(ownerPassword.count)
+        guard ownerPassword.characters.count <= type(of: self).PasswordLengthMax else {
+            throw PDFGenerateError.tooLongPassword(ownerPassword.characters.count)
         }
     }
 }

+ 19 - 0
Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/DPITests.swift

@@ -0,0 +1,19 @@
+//
+//  DPITests.swift
+//  PDFGenerator
+//
+//  Created by Suguru Kishimoto on 7/23/16.
+//
+//
+
+import XCTest
+@testable import PDFGenerator
+
+class DPITests: XCTestCase {
+    func test() {
+        XCTAssertEqual(DPIType.default.value, 72.0)
+        XCTAssertEqual(DPIType.dpi_300.value, 300.0)
+        XCTAssertEqual(DPIType.custom(100.0).value, 100.0)
+        XCTAssertEqual(DPIType.custom(-100.0).value, DPIType.default.value)
+    }
+}

+ 29 - 0
Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/FilePathConvertibleTests.swift

@@ -0,0 +1,29 @@
+//
+//  FilePathConvertibleTests.swift
+//  PDFGenerator
+//
+//  Created by Suguru Kishimoto on 7/23/16.
+//
+//
+
+import XCTest
+@testable import PDFGenerator
+
+class FilePathConvertibleTests: XCTestCase {
+    
+    func test() {
+        let p1: FilePathConvertible = ""
+        XCTAssertNotNil(p1.url)
+        XCTAssertEqual(p1.path, "")
+        XCTAssertEqual(p1.url, URL(fileURLWithPath: ""))
+
+        let p2: FilePathConvertible = "path/to/hoge.txt"
+        XCTAssertNotNil(p2.url)
+        XCTAssertEqual(p2.url, URL(fileURLWithPath: "path/to/hoge.txt"))
+        XCTAssertEqual(p2.path, "path/to/hoge.txt")
+
+        let p3: FilePathConvertible = URL(fileURLWithPath: "path/to/hoge.txt")
+        XCTAssertNotNil(p3.url)
+        XCTAssertEqual(p3.url, URL(fileURLWithPath: "path/to/hoge.txt"))
+    }
+}

TEMPAT SAMPAH
Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/Images/test_image1.png


+ 24 - 0
Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/Info.plist

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>$(EXECUTABLE_NAME)</string>
+	<key>CFBundleIdentifier</key>
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>$(PRODUCT_NAME)</string>
+	<key>CFBundlePackageType</key>
+	<string>BNDL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>1</string>
+</dict>
+</plist>

+ 462 - 0
Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/PDFGeneratorTests.swift

@@ -0,0 +1,462 @@
+//
+//  PDFGeneratorTests.swift
+//  PDFGeneratorTests
+//
+//  Created by Suguru Kishimoto on 2016/02/04.
+//
+//
+
+import XCTest
+@testable import PDFGenerator
+
+class Mock {
+    struct ImageName {
+        static let testImage1 = "test_image1"
+    }
+    
+    class func view(_ size: CGSize) -> UIView {
+        return UIView(frame: CGRect(origin: CGPoint.zero, size: size))
+    }
+    
+    class func scrollView(_ size: CGSize) -> UIScrollView {
+        return { () -> UIScrollView in
+            let v = UIScrollView(frame: CGRect(origin: CGPoint.zero, size: size))
+            v.contentSize = v.frame.size
+            return v
+        }()
+    }
+
+    class func imagePath(_ name: String) -> String{
+        return Bundle(for: self).path(forResource: name, ofType: "png")!
+    }
+    
+    class func image(_ name: String) -> UIImage {
+        return UIImage(contentsOfFile: imagePath(name))!
+    }
+    
+}
+
+class PDFGeneratorTests: XCTestCase {
+    
+    func isExistPDF(_ path: String) -> Bool {
+        return FileManager.default.fileExists(atPath: path)
+    }
+    
+    func PDFDirectoryPath() -> String {
+        return NSHomeDirectory() + "/test/"
+    }
+    
+    func PDFfilePath(_ fileName: String) -> String {
+        return PDFDirectoryPath() + "/\(fileName)"
+    }
+    
+    override func setUp() {
+        super.setUp()
+        try! FileManager.default.createDirectory(
+            atPath: PDFDirectoryPath(),
+            withIntermediateDirectories: true,
+            attributes: nil
+        )
+    }
+    
+    override func tearDown() {
+        _ = try? FileManager.default.removeItem(atPath: PDFDirectoryPath())
+        super.tearDown()
+    }
+    
+    // MARK: UIView -> PDF
+    func testViewToPDF() {
+        let view = Mock.view(CGSize(width: 100, height: 100))
+        let view2 = Mock.scrollView(CGSize(width: 100, height: 100))
+        
+        let path1 = PDFfilePath("test_sample1.pdf")
+        _ = try? PDFGenerator.generate(view, to: path1)
+        XCTAssertTrue(isExistPDF(path1))
+        
+        let path2 = PDFfilePath("hoge/test_sample2.pdf")
+        _ = try? PDFGenerator.generate(view, to: path2)
+        XCTAssertFalse(isExistPDF(path2))
+        
+        let path3 = PDFfilePath("test_sample3.pdf")
+        _ = try? PDFGenerator.generate(view, to: path3)
+        XCTAssertTrue(isExistPDF(path3))
+        
+        XCTAssertNotNil(try? PDFGenerator.generated(by: view))
+        XCTAssertNotNil(try? PDFGenerator.generated(by: [view]))
+        XCTAssertNotNil(try? PDFGenerator.generated(by: [view, view2]))
+    }
+    
+    // MARK: UIImage -> PDF
+    func testImageToPDF() {
+        let image1 = Mock.image("test_image1")
+        let image2 = Mock.image("test_image1")
+        
+        let path1 = PDFfilePath("test_sample1.pdf")
+        _ = try? PDFGenerator.generate(image1, to: path1)
+        XCTAssertTrue(isExistPDF(path1))
+        
+        let path2 = PDFfilePath("hoge/test_sample2.pdf")
+        _ = try? PDFGenerator.generate(image1, to: path2)
+        XCTAssertFalse(isExistPDF(path2))
+        
+        let path3 = PDFfilePath("test_sample3.pdf")
+        _ = try? PDFGenerator.generate([image1, image2], to: path3)
+        XCTAssertTrue(isExistPDF(path3))
+        
+        XCTAssertNotNil(try? PDFGenerator.generated(by: image1))
+        XCTAssertNotNil(try? PDFGenerator.generated(by: [image1]))
+        XCTAssertNotNil(try? PDFGenerator.generated(by: [image1, image2]))
+    }
+    
+    // MARK: ImagePath(String) -> PDF
+    func testImagePathToPDF() {
+        let image1 = Mock.imagePath("test_image1")
+        let image2 = Mock.imagePath("test_image1")
+        
+        let path1 = PDFfilePath("test_sample1.pdf")
+        _ = try? PDFGenerator.generate(image1, to: path1)
+        XCTAssertTrue(isExistPDF(path1))
+        
+        let path2 = PDFfilePath("hoge/test_sample2.pdf")
+        _ = try? PDFGenerator.generate(image1, to: path2)
+        XCTAssertFalse(isExistPDF(path2))
+        
+        let path3 = PDFfilePath("test_sample3.pdf")
+        _ = try? PDFGenerator.generate([image1, image2], to: path3)
+        XCTAssertTrue(isExistPDF(path3))
+        
+        XCTAssertNotNil(try? PDFGenerator.generated(by: image1))
+        XCTAssertNotNil(try? PDFGenerator.generated(by: [image1]))
+        XCTAssertNotNil(try? PDFGenerator.generated(by: [image1, image2]))
+    }
+    
+    // MARK: PDFPage -> PDF
+    func testMixedPageToPDF() {
+        let p1 = PDFPage.view(Mock.view(CGSize(width: 100, height: 100)))
+        let p2 = PDFPage.image(Mock.image(Mock.ImageName.testImage1))
+        let p3 = PDFPage.imagePath(Mock.imagePath(Mock.ImageName.testImage1))
+        let p4 = PDFPage.whitePage(CGSize(width: 100, height: 100))
+        let p5 = PDFPage.imageRef(Mock.image(Mock.ImageName.testImage1).cgImage!)
+        let p6 = PDFPage.binary(UIImagePNGRepresentation(Mock.image(Mock.ImageName.testImage1))!)
+        
+        let path1 = PDFfilePath("test_sample1.pdf")
+        _ = try? PDFGenerator.generate(p1, to: path1)
+        XCTAssertTrue(isExistPDF(path1))
+
+        let path2 = PDFfilePath("hoge/test_sample2.pdf")
+        _ = try? PDFGenerator.generate(p2, to: path2)
+        XCTAssertFalse(isExistPDF(path2))
+        
+        let path3 = PDFfilePath("test_sample3.pdf")
+        _ = try? PDFGenerator.generate([p1, p2, p3, p4], to: path3)
+        XCTAssertTrue(isExistPDF(path3))
+
+        XCTAssertNotNil(try? PDFGenerator.generated(by: p1))
+        XCTAssertNotNil(try? PDFGenerator.generated(by: [p2]))
+        XCTAssertNotNil(try? PDFGenerator.generated(by: [p3, p4]))
+        XCTAssertNotNil(try? PDFGenerator.generated(by: [p5, p6]))
+
+    }
+    
+    // swiftlint:disable function_body_length
+    func testErrors() {
+        let view = Mock.view(CGSize(width: 100, height: 100))
+        let image = Mock.image(Mock.ImageName.testImage1)
+        let imagePath = Mock.imagePath(Mock.ImageName.testImage1)
+        let viewPage = PDFPage.view(Mock.view(CGSize(width: 100, height: 100)))
+        let imagePage = PDFPage.image(Mock.image(Mock.ImageName.testImage1))
+        let imagePathPage = PDFPage.imagePath(Mock.imagePath(Mock.ImageName.testImage1))
+        let whitePage = PDFPage.whitePage(CGSize(width: 100, height: 100))
+        let views = [
+            Mock.view(CGSize(width: 100, height: 100)),
+            Mock.view(CGSize(width: 100, height: 100))
+        ]
+        let images = [
+            Mock.image(Mock.ImageName.testImage1),
+            Mock.image(Mock.ImageName.testImage1)
+        ]
+        let imagePaths = [
+            Mock.imagePath(Mock.ImageName.testImage1),
+            Mock.imagePath(Mock.ImageName.testImage1)
+        ]
+        
+        let pages = [
+            PDFPage.view(Mock.view(CGSize(width: 100, height: 100))),
+            PDFPage.image(Mock.image(Mock.ImageName.testImage1)),
+            PDFPage.imagePath(Mock.imagePath(Mock.ImageName.testImage1)),
+            PDFPage.whitePage(CGSize(width: 100, height: 100))
+        ]
+
+        let mocks: [Any] = [
+            view,
+            image,
+            imagePath,
+            viewPage,
+            imagePage,
+            imagePathPage,
+            whitePage,
+            views,
+            images,
+            imagePaths,
+            pages
+        ]
+        
+        let emptyMocks: [Any] = [
+            [UIView](),
+            [UIImage](),
+            [String](),
+            [PDFPage]()
+        ]
+        
+        // MARK: check EmptyOutputPath
+        mocks.forEach {
+            do {
+                if let page = $0 as? UIView {
+                    try PDFGenerator.generate(page, to: "")
+                } else if let page = $0 as? UIImage {
+                    try PDFGenerator.generate(page, to: "")
+                } else if let page = $0 as? String {
+                    try PDFGenerator.generate(page, to: "")
+                } else if let page = $0 as? PDFPage {
+                    try PDFGenerator.generate(page, to: "")
+                } else if let pages = $0 as? [UIView] {
+                    try PDFGenerator.generate(pages, to: "")
+                } else if let pages = $0 as? [UIImage] {
+                    try PDFGenerator.generate(pages, to: "")
+                } else if let pages = $0 as? [String] {
+                    try PDFGenerator.generate(pages, to: "")
+                } else if let pages = $0 as? [PDFPage] {
+                    try PDFGenerator.generate(pages, to: "")
+                } else {
+                    XCTFail("invalid page(s) type found.")
+                }
+                XCTFail("[\($0)] No create PDF from empty name image path.")
+            } catch PDFGenerateError.emptyOutputPath {
+                // Right Error
+            } catch (let e) {
+                XCTFail("[\($0)] Unknown or wrong error occurred.\(e)")
+            }
+        }
+        
+        // MARK: check EmptyPage
+        emptyMocks.forEach {
+            do {
+                let path = PDFfilePath("test_sample1.pdf")
+                if let pages = $0 as? [UIView] {
+                    try PDFGenerator.generate(pages, to: path)
+                } else if let pages = $0 as? [UIImage] {
+                    try PDFGenerator.generate(pages, to: path)
+                } else if let pages = $0 as? [String] {
+                    try PDFGenerator.generate(pages, to: path)
+                } else if let pages = $0 as? [PDFPage] {
+                    try PDFGenerator.generate(pages, to: path)
+                } else {
+                    XCTFail("invalid pages type found.")
+                }
+                XCTFail("[\($0)] No create PDF from empty name image path.")
+            } catch PDFGenerateError.emptyPage {
+                // Right Error
+            } catch (let e) {
+                XCTFail("[\($0)] Unknown or wrong error occurred.\(e)")
+            }
+        }
+        
+        // MARK: check EmptyPage
+        emptyMocks.forEach {
+            do {
+                if let pages = $0 as? [UIView] {
+                    _ = try PDFGenerator.generated(by: pages)
+                } else if let pages = $0 as? [UIImage] {
+                    _ = try PDFGenerator.generated(by: pages)
+                } else if let pages = $0 as? [String] {
+                    _ = try PDFGenerator.generated(by: pages)
+                } else if let pages = $0 as? [PDFPage] {
+                    _ = try PDFGenerator.generated(by: pages)
+                } else {
+                    XCTFail("invalid pages type found.")
+                }
+                XCTFail("[\($0)] No create PDF from empty name image path.")
+            } catch PDFGenerateError.emptyPage {
+                // Right Error
+            } catch (let e) {
+                XCTFail("[\($0)] Unknown or wrong error occurred.\(e)")
+            }
+        }
+        
+        // MARK: check ZeroSizeView
+        let emptyView = Mock.view(CGSize.zero)
+        do {
+            let path = PDFfilePath("test_sample2.pdf")
+            try PDFGenerator.generate(emptyView, to: path)
+        } catch PDFGenerateError.zeroSizeView(let v) {
+            XCTAssertEqual(emptyView, v)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+        do {
+            _ = try PDFGenerator.generated(by: emptyView)
+        } catch PDFGenerateError.zeroSizeView(let v) {
+            XCTAssertEqual(emptyView, v)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+        do {
+            _ = try PDFGenerator.generated(by: [emptyView])
+        } catch PDFGenerateError.zeroSizeView(let v) {
+            XCTAssertEqual(emptyView, v)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+        
+        let emptyViewPage = PDFPage.view(emptyView)
+        do {
+            let path = PDFfilePath("test_sample3.pdf")
+            try PDFGenerator.generate(emptyViewPage, to: path)
+        } catch PDFGenerateError.zeroSizeView(let v) {
+            XCTAssertEqual(emptyView, v)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+        do {
+            _ = try PDFGenerator.generated(by: emptyViewPage)
+        } catch PDFGenerateError.zeroSizeView(let v) {
+            XCTAssertEqual(emptyView, v)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+        do {
+            _ = try PDFGenerator.generated(by: [emptyViewPage])
+        } catch PDFGenerateError.zeroSizeView(let v) {
+            XCTAssertEqual(emptyView, v)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+
+        // MARK: check ImageLoadFailed
+        let wrongImagePath = "wrong/image.png"
+        do {
+            let path = PDFfilePath("test_sample4.pdf")
+            try PDFGenerator.generate(wrongImagePath, to: path)
+        } catch PDFGenerateError.imageLoadFailed(let ip) {
+            XCTAssertEqual(wrongImagePath, ip as? String)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+        do {
+            _ = try PDFGenerator.generated(by: wrongImagePath)
+        } catch PDFGenerateError.imageLoadFailed(let ip) {
+            XCTAssertEqual(wrongImagePath, ip as? String)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+        do {
+            _ = try PDFGenerator.generated(by: [wrongImagePath])
+        } catch PDFGenerateError.imageLoadFailed(let ip) {
+            XCTAssertEqual(wrongImagePath, ip as? String)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+
+        let wrongImagePathPage = PDFPage.imagePath(wrongImagePath)
+        do {
+            let path = PDFfilePath("test_sample5.pdf")
+            try PDFGenerator.generate(wrongImagePathPage, to: path)
+        } catch PDFGenerateError.imageLoadFailed(let ip) {
+            XCTAssertEqual(wrongImagePath, ip as? String)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+        do {
+            _ = try PDFGenerator.generated(by: wrongImagePathPage)
+        } catch PDFGenerateError.imageLoadFailed(let ip) {
+            XCTAssertEqual(wrongImagePath, ip as? String)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+        do {
+            _ = try PDFGenerator.generated(by: [wrongImagePathPage])
+        } catch PDFGenerateError.imageLoadFailed(let ip) {
+            XCTAssertEqual(wrongImagePath, ip as? String)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+        
+        let wrongData = Data()
+        
+        do {
+            _ = try PDFGenerator.generated(by: PDFPage.binary(wrongData))
+        } catch PDFGenerateError.imageLoadFailed(let data) {
+            XCTAssertEqual(wrongData, data as? Data)
+        } catch (let e) {
+            XCTFail("Unknown or wrong error occurred.\(e)")
+        }
+
+    }
+    // swiftlint:enable function_body_length
+    
+    func testPDFPassword() {
+        let view = Mock.view(CGSize(width: 100, height: 100))
+        let view2 = Mock.view(CGSize(width: 100, height: 100))
+        
+        let path1 = PDFfilePath("test_sample1.pdf")
+        _ = try? PDFGenerator.generate(view, to: path1, password: "abcdef")
+        XCTAssertTrue(isExistPDF(path1))
+        
+        let path2 = PDFfilePath("test_sample2.pdf")
+        _ = try? PDFGenerator.generate(view, to: path2, password: "⌘123456")
+        XCTAssertFalse(isExistPDF(path2))
+        
+        let path3 = PDFfilePath("test_sample3.pdf")
+        do {
+            try PDFGenerator.generate([view, view2], to: path3, password: "123456")
+        } catch {
+            XCTFail()
+        }
+
+        let path4 = PDFfilePath("test_sample4.pdf")
+        do {
+            try PDFGenerator.generate([view, view2], to: path4, password: "⌘123456")
+            XCTFail()
+        } catch PDFGenerateError.invalidPassword(let password) {
+            XCTAssertEqual(password, "⌘123456")
+        } catch {
+            XCTFail()
+        }
+
+        let path5 = PDFfilePath("test_sample5.pdf")
+        do {
+            try PDFGenerator.generate([view, view2], to: path5, password: "0123456789abcdef0123456789abcdefA")
+            XCTFail()
+        } catch PDFGenerateError.tooLongPassword(let length) {
+            XCTAssertEqual(length, 33)
+        } catch {
+            XCTFail()
+        }
+
+        XCTAssertNotNil(try? PDFGenerator.generated(by: view, password: "abcdef"))
+        XCTAssertNil(try? PDFGenerator.generated(by: [view], password: "⌘123456"))
+        
+        do {
+            _ = try PDFGenerator.generated(by: [view], password: "123456")
+        } catch {
+            XCTFail()
+        }
+
+        do {
+            _ = try PDFGenerator.generated(by: [view], password: "⌘123456")
+        } catch PDFGenerateError.invalidPassword(let password) {
+            XCTAssertEqual(password, "⌘123456")
+        } catch {
+            XCTFail()
+        }
+        
+        do {
+            _ = try PDFGenerator.generated(by: [view], password: "0123456789abcdef0123456789abcdefA")
+            XCTFail()
+        } catch PDFGenerateError.tooLongPassword(let length) {
+            XCTAssertEqual(length, 33)
+        } catch {
+            XCTFail()
+        }
+    }
+}

+ 71 - 0
Carthage/Checkouts/PDFGenerator/PDFGeneratorTests/PDFPasswordTests.swift

@@ -0,0 +1,71 @@
+//
+//  PDFPasswordTests.swift
+//  PDFGenerator
+//
+//  Created by Suguru Kishimoto on 7/23/16.
+//
+//
+
+import XCTest
+@testable import PDFGenerator
+class PDFPasswordTests: XCTestCase {
+    func test() {
+        let p1: PDFPassword = "123456"
+        XCTAssertEqual(p1.userPassword, "123456")
+        XCTAssertEqual(p1.ownerPassword, "123456")
+        do {
+            try p1.verify()
+        } catch _ {
+            XCTFail()
+        }
+        
+        let p2: PDFPassword = PDFPassword(user: "123456", owner: "abcdef")
+        XCTAssertNotEqual(p2.userPassword, p2.ownerPassword)
+        do {
+            try p2.verify()
+        } catch _ {
+            XCTFail()
+        }
+
+        let p3: PDFPassword = PDFPassword(user: "ああああ", owner: "abcdef")
+        do {
+            try p3.verify()
+            XCTFail()
+        } catch PDFGenerateError.invalidPassword(let password) {
+            XCTAssertEqual(p3.userPassword, password)
+        } catch _ {
+            XCTFail()
+        }
+        
+        let p4: PDFPassword = PDFPassword(user: "123456", owner: "ああああ")
+        do {
+            try p4.verify()
+            XCTFail()
+        } catch PDFGenerateError.invalidPassword(let password) {
+            XCTAssertEqual(p4.ownerPassword, password)
+        } catch _ {
+            XCTFail()
+        }
+        
+        let p5: PDFPassword = PDFPassword(user: "1234567890123456789012345678901234567890", owner: "abcdef")
+        do {
+            try p5.verify()
+            XCTFail()
+        } catch PDFGenerateError.tooLongPassword(let length) {
+            XCTAssertEqual(p5.userPassword.characters.count, length)
+        } catch _ {
+            XCTFail()
+        }
+        
+        let p6: PDFPassword = PDFPassword(user: "123456", owner: "abcdefghijabcdefghijabcdefghijabcdefghij")
+        do {
+            try p6.verify()
+            XCTFail()
+        } catch PDFGenerateError.tooLongPassword(let length) {
+            XCTAssertEqual(p6.ownerPassword.characters.count, length)
+        } catch _ {
+            XCTFail()
+        }
+
+    }
+}

+ 3 - 0
Carthage/Checkouts/PDFGenerator/Package.swift

@@ -0,0 +1,3 @@
+import PackageDescription
+
+let package = Package(name: "PDFGenerator")

+ 6 - 0
Carthage/Checkouts/PDFGenerator/codecov.yml

@@ -0,0 +1,6 @@
+coverage:
+    ignore: 
+        - "Demo/*"
+        - "PDFGeneratorTests/*"
+
+comment: false

+ 6 - 39
Nextcloud.xcodeproj/project.pbxproj

@@ -247,13 +247,6 @@
 		F754EECB21772B6100BB1CDF /* DropdownMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F754EEC721772B6100BB1CDF /* DropdownMenu.swift */; };
 		F754EECC21772B6100BB1CDF /* SectionHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = F754EEC821772B6100BB1CDF /* SectionHeader.swift */; };
 		F755BD9B20594AC7008C5FBB /* NCService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F755BD9A20594AC7008C5FBB /* NCService.swift */; };
-		F758B3E1212C4A6C00515F55 /* PDFPageRenderable.swift in Sources */ = {isa = PBXBuildFile; fileRef = F758B3D9212C4A6C00515F55 /* PDFPageRenderable.swift */; };
-		F758B3E2212C4A6C00515F55 /* DPIType.swift in Sources */ = {isa = PBXBuildFile; fileRef = F758B3DA212C4A6C00515F55 /* DPIType.swift */; };
-		F758B3E3212C4A6C00515F55 /* PDFPassword.swift in Sources */ = {isa = PBXBuildFile; fileRef = F758B3DB212C4A6C00515F55 /* PDFPassword.swift */; };
-		F758B3E4212C4A6C00515F55 /* PDFGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F758B3DC212C4A6C00515F55 /* PDFGenerator.swift */; };
-		F758B3E5212C4A6C00515F55 /* FilePathConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = F758B3DD212C4A6C00515F55 /* FilePathConvertible.swift */; };
-		F758B3E6212C4A6C00515F55 /* PDFPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = F758B3DE212C4A6C00515F55 /* PDFPage.swift */; };
-		F758B3E7212C4A6C00515F55 /* PDFGenerateError.swift in Sources */ = {isa = PBXBuildFile; fileRef = F758B3DF212C4A6C00515F55 /* PDFGenerateError.swift */; };
 		F758B43E212C516300515F55 /* ImageScannerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F758B420212C516300515F55 /* ImageScannerController.swift */; };
 		F758B43F212C516300515F55 /* RectangleFeaturesFunnel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F758B422212C516300515F55 /* RectangleFeaturesFunnel.swift */; };
 		F758B440212C516300515F55 /* CaptureSessionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F758B423212C516300515F55 /* CaptureSessionManager.swift */; };
@@ -467,6 +460,7 @@
 		F7BB14971D5B62C000ECEE68 /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F70A63071D5B3467004E2AA5 /* libssl.a */; };
 		F7BE6E2F1D2D5C3B00106933 /* CCQuickActions.m in Sources */ = {isa = PBXBuildFile; fileRef = F7BE6E2C1D2D5C3B00106933 /* CCQuickActions.m */; };
 		F7BF1B431D51E893000854F6 /* CCLogin.m in Sources */ = {isa = PBXBuildFile; fileRef = F7BF1B401D51E893000854F6 /* CCLogin.m */; };
+		F7C40BE321998C060004137E /* PDFGenerator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7C40BE221998C050004137E /* PDFGenerator.framework */; };
 		F7C525A01E3B48B700FFE02C /* CCNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C5259F1E3B48B700FFE02C /* CCNotification.swift */; };
 		F7C525A21E3B6DA800FFE02C /* CCNotification.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7C525A11E3B6DA800FFE02C /* CCNotification.storyboard */; };
 		F7CA1ED020E7E3FE002CC65E /* UIImage+PKDownloadButton.m in Sources */ = {isa = PBXBuildFile; fileRef = F7CA1EBC20E7E3FE002CC65E /* UIImage+PKDownloadButton.m */; };
@@ -963,14 +957,6 @@
 		F754EEC721772B6100BB1CDF /* DropdownMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DropdownMenu.swift; sourceTree = "<group>"; };
 		F754EEC821772B6100BB1CDF /* SectionHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SectionHeader.swift; sourceTree = "<group>"; };
 		F755BD9A20594AC7008C5FBB /* NCService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCService.swift; sourceTree = "<group>"; };
-		F758B3D9212C4A6C00515F55 /* PDFPageRenderable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFPageRenderable.swift; sourceTree = "<group>"; };
-		F758B3DA212C4A6C00515F55 /* DPIType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DPIType.swift; sourceTree = "<group>"; };
-		F758B3DB212C4A6C00515F55 /* PDFPassword.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFPassword.swift; sourceTree = "<group>"; };
-		F758B3DC212C4A6C00515F55 /* PDFGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFGenerator.swift; sourceTree = "<group>"; };
-		F758B3DD212C4A6C00515F55 /* FilePathConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilePathConvertible.swift; sourceTree = "<group>"; };
-		F758B3DE212C4A6C00515F55 /* PDFPage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFPage.swift; sourceTree = "<group>"; };
-		F758B3DF212C4A6C00515F55 /* PDFGenerateError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFGenerateError.swift; sourceTree = "<group>"; };
-		F758B3E0212C4A6C00515F55 /* PDFGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFGenerator.h; sourceTree = "<group>"; };
 		F758B420212C516300515F55 /* ImageScannerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageScannerController.swift; sourceTree = "<group>"; };
 		F758B422212C516300515F55 /* RectangleFeaturesFunnel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RectangleFeaturesFunnel.swift; sourceTree = "<group>"; };
 		F758B423212C516300515F55 /* CaptureSessionManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaptureSessionManager.swift; sourceTree = "<group>"; };
@@ -1264,6 +1250,7 @@
 		F7BFCCC11B68C21900548E76 /* CCManageLocation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCManageLocation.m; sourceTree = "<group>"; };
 		F7C0F46E1C8880540059EC54 /* ShareViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = ShareViewController.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
 		F7C0F46F1C8880540059EC54 /* ShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = ShareViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
+		F7C40BE221998C050004137E /* PDFGenerator.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PDFGenerator.framework; path = Carthage/Build/iOS/PDFGenerator.framework; sourceTree = "<group>"; };
 		F7C5259F1E3B48B700FFE02C /* CCNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CCNotification.swift; path = Notification/CCNotification.swift; sourceTree = "<group>"; };
 		F7C525A11E3B6DA800FFE02C /* CCNotification.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = CCNotification.storyboard; path = Notification/CCNotification.storyboard; sourceTree = "<group>"; };
 		F7C742C01E7BD01F00D9C973 /* iOSClient.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = iOSClient.entitlements; sourceTree = "<group>"; };
@@ -1511,6 +1498,7 @@
 				F72D0FFD210B6638009C96B7 /* GoogleToolboxForMac.framework in Frameworks */,
 				F72D0FF9210B6638009C96B7 /* Protobuf.framework in Frameworks */,
 				F72D0FFB210B6638009C96B7 /* FirebaseCore.framework in Frameworks */,
+				F7C40BE321998C060004137E /* PDFGenerator.framework in Frameworks */,
 				F72D1000210B6638009C96B7 /* FirebaseInstanceID.framework in Frameworks */,
 				F7BB14961D5B62C000ECEE68 /* libcrypto.a in Frameworks */,
 				F7BB14971D5B62C000ECEE68 /* libssl.a in Frameworks */,
@@ -1681,7 +1669,6 @@
 				F7DC5FD31F00F98B00A903C7 /* MGSwipeTableCell */,
 				F7B2DEEB1F976785007CF4D2 /* NYMnemonic */,
 				F7540EE11D5B238600C3FFA8 /* openssl */,
-				F758B3D8212C4A6C00515F55 /* PDFGenerator */,
 				F7CA1EBB20E7E3FE002CC65E /* PKDownloadButton */,
 				F75037421DBFA91A008FB480 /* PureLayout */,
 				F70F05241C889184008DAB36 /* Reachability */,
@@ -2076,21 +2063,6 @@
 			path = DropdownMenu;
 			sourceTree = "<group>";
 		};
-		F758B3D8212C4A6C00515F55 /* PDFGenerator */ = {
-			isa = PBXGroup;
-			children = (
-				F758B3D9212C4A6C00515F55 /* PDFPageRenderable.swift */,
-				F758B3DA212C4A6C00515F55 /* DPIType.swift */,
-				F758B3DB212C4A6C00515F55 /* PDFPassword.swift */,
-				F758B3DC212C4A6C00515F55 /* PDFGenerator.swift */,
-				F758B3DD212C4A6C00515F55 /* FilePathConvertible.swift */,
-				F758B3DE212C4A6C00515F55 /* PDFPage.swift */,
-				F758B3DF212C4A6C00515F55 /* PDFGenerateError.swift */,
-				F758B3E0212C4A6C00515F55 /* PDFGenerator.h */,
-			);
-			path = PDFGenerator;
-			sourceTree = "<group>";
-		};
 		F758B41E212C516300515F55 /* Scan */ = {
 			isa = PBXGroup;
 			children = (
@@ -3125,6 +3097,7 @@
 		F7FC7D541DC1F93700BB2C6A /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				F7C40BE221998C050004137E /* PDFGenerator.framework */,
 				F79918A72199840500C2E308 /* Sheeeeeeeeet.framework */,
 				F79918A021997F9000C2E308 /* UICKeyChainStore.framework */,
 				F733B65121997CC1001C1FFA /* TLPhotoPicker.framework */,
@@ -3545,7 +3518,7 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
-			shellScript = "#!/bin/bash\n# buildNumber=$(/usr/libexec/PlistBuddy -c \"Print CFBundleVersion\" \"$INFOPLIST_FILE\")\n# buildNumber=$(echo $buildNumber | sed 's/0*//')\n# buildNumber=$(($buildNumber + 1))\n# buildNumber=$(printf \"%04d\" $buildNumber)\n# /usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $buildNumber\" \"$INFOPLIST_FILE\"";
+			shellScript = "#!/bin/bash\n# buildNumber=$(/usr/libexec/PlistBuddy -c \"Print CFBundleVersion\" \"$INFOPLIST_FILE\")\n# buildNumber=$(echo $buildNumber | sed 's/0*//')\n# buildNumber=$(($buildNumber + 1))\n# buildNumber=$(printf \"%04d\" $buildNumber)\n# /usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $buildNumber\" \"$INFOPLIST_FILE\"\n";
 		};
 		F75A40001EBCB82B00B213E8 /* ShellScript */ = {
 			isa = PBXShellScriptBuildPhase;
@@ -3556,6 +3529,7 @@
 				"$(SRCROOT)/Carthage/Build/iOS/Sheeeeeeeeet.framework",
 				"$(SRCROOT)/Carthage/Build/iOS/TLPhotoPicker.framework",
 				"$(SRCROOT)/Carthage/Build/iOS/UICKeyChainStore.framework",
+				"$(SRCROOT)/Carthage/Build/iOS/PDFGenerator.framework",
 			);
 			outputPaths = (
 			);
@@ -3774,7 +3748,6 @@
 				F7D423801F0596C6009C9782 /* ReaderMainPagebar.m in Sources */,
 				F762CB061EACB66200B38484 /* XLFormTextViewCell.m in Sources */,
 				F78ACD4221903CE00088454D /* NCListCell.swift in Sources */,
-				F758B3E7212C4A6C00515F55 /* PDFGenerateError.swift in Sources */,
 				F78ACD4F2190440D0088454D /* NCLayout.swift in Sources */,
 				F762CB881EACB81000B38484 /* REMenuContainerView.m in Sources */,
 				F7D4237F1F0596C6009C9782 /* ReaderDocumentOutline.m in Sources */,
@@ -3782,7 +3755,6 @@
 				F73B4EF71F470D9100BBEE4B /* LangBulgarianModel.cpp in Sources */,
 				F7F54D0C1E5B14C800E19C62 /* MWTapDetectingView.m in Sources */,
 				F758B444212C516300515F55 /* AVCaptureVideoOrientation+Utils.swift in Sources */,
-				F758B3E4212C4A6C00515F55 /* PDFGenerator.swift in Sources */,
 				F7B1FBC61E72E3D1001781FE /* SwiftModalWebVC.swift in Sources */,
 				F7A5541F204EF8AF008468EC /* TOScrollBar.m in Sources */,
 				F7A321651E9E37960069AD1B /* CCActivity.m in Sources */,
@@ -3811,7 +3783,6 @@
 				F7D423871F0596C6009C9782 /* ReaderThumbsView.m in Sources */,
 				F758B451212C516300515F55 /* QuadrilateralView.swift in Sources */,
 				F758B44D212C516300515F55 /* EditScanViewController.swift in Sources */,
-				F758B3E2212C4A6C00515F55 /* DPIType.swift in Sources */,
 				F77B0E201D118A16002130FE /* CCShareUserOC.m in Sources */,
 				F7B1FBCA1E72E3D1001781FE /* SwiftWebVCActivitySafari.swift in Sources */,
 				F7F54D0A1E5B14C800E19C62 /* MWPhotoBrowser.m in Sources */,
@@ -3865,7 +3836,6 @@
 				F7A5541E204EF8AF008468EC /* TOScrollBarGestureRecognizer.m in Sources */,
 				F758B452212C516300515F55 /* Quadrilateral.swift in Sources */,
 				F70022E61EC4C9100080073F /* OCXMLServerErrorsParser.m in Sources */,
-				F758B3E1212C4A6C00515F55 /* PDFPageRenderable.swift in Sources */,
 				F762CB171EACB66200B38484 /* XLFormRegexValidator.m in Sources */,
 				F758B44F212C516300515F55 /* Error.swift in Sources */,
 				F729B92D217A2F1B00FE2150 /* NCActionSheetHeaderView.swift in Sources */,
@@ -3952,7 +3922,6 @@
 				F70022B31EC4C9100080073F /* OCActivity.m in Sources */,
 				F70022D41EC4C9100080073F /* NSDate+ISO8601.m in Sources */,
 				F78964AD1EBB576C00403E13 /* JDStatusBarNotification.m in Sources */,
-				F758B3E3212C4A6C00515F55 /* PDFPassword.swift in Sources */,
 				F758B44C212C516300515F55 /* ZoomGestureController.swift in Sources */,
 				F762CB151EACB66200B38484 /* XLFormRowNavigationAccessoryView.m in Sources */,
 				F77B0EB61D118A16002130FE /* MBProgressHUD.m in Sources */,
@@ -3974,7 +3943,6 @@
 				F73B4F031F470D9100BBEE4B /* LangVietnameseModel.cpp in Sources */,
 				F73B4F021F470D9100BBEE4B /* LangTurkishModel.cpp in Sources */,
 				F7F54D0B1E5B14C800E19C62 /* MWTapDetectingImageView.m in Sources */,
-				F758B3E5212C4A6C00515F55 /* FilePathConvertible.swift in Sources */,
 				F7D423821F0596C6009C9782 /* ReaderThumbCache.m in Sources */,
 				F70022A71EC4C9100080073F /* AFSecurityPolicy.m in Sources */,
 				F78964AF1EBB576C00403E13 /* JDStatusBarView.m in Sources */,
@@ -3983,7 +3951,6 @@
 				F762CB0B1EACB66200B38484 /* XLFormRowDescriptor.m in Sources */,
 				F7169A1C1EE590930086BD69 /* NCShares.m in Sources */,
 				F77B0EC61D118A16002130FE /* CCCellMain.m in Sources */,
-				F758B3E6212C4A6C00515F55 /* PDFPage.swift in Sources */,
 				F7DC5FED1F011EB700A903C7 /* MGSwipeTableCell.m in Sources */,
 				F7D4238B1F0596C6009C9782 /* ThumbsViewController.m in Sources */,
 				F70022B61EC4C9100080073F /* OCCapabilities.m in Sources */,

+ 1 - 0
iOSClient/Main/CCCreateCloud.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import PDFGenerator
 
 // MARK: -
 

+ 1 - 0
iOSClient/Scan/ScanCollectionView.swift

@@ -22,6 +22,7 @@
 //
 
 import UIKit
+import PDFGenerator
 
 @available(iOS 11, *)