diff --git a/Demo/Base.lproj/Main.storyboard b/Demo/Base.lproj/Main.storyboard index 03749d8..3659b74 100644 --- a/Demo/Base.lproj/Main.storyboard +++ b/Demo/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -52,9 +52,18 @@ + + + diff --git a/Demo/Info.plist b/Demo/Info.plist index 6905cc6..a55c24b 100644 --- a/Demo/Info.plist +++ b/Demo/Info.plist @@ -36,5 +36,10 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + diff --git a/Demo/SampleTableViewController.storyboard b/Demo/SampleTableViewController.storyboard index aea8d78..013c3c2 100644 --- a/Demo/SampleTableViewController.storyboard +++ b/Demo/SampleTableViewController.storyboard @@ -1,5 +1,5 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/Demo/ViewController.swift b/Demo/ViewController.swift index d30d60a..f3699c7 100644 --- a/Demo/ViewController.swift +++ b/Demo/ViewController.swift @@ -134,5 +134,12 @@ class ViewController: UIViewController { let vc = storyboard.instantiateInitialViewController() as! SampleTableViewController presentViewController(vc, animated: true, completion: nil) } + + @objc @IBAction private func goSampleWebView(sender: AnyObject?) { + let storyboard = UIStoryboard(name: "WebViewController", bundle: nil) + let vc = storyboard.instantiateInitialViewController() as! WebViewController + presentViewController(vc, animated: true, completion: nil) + } + } diff --git a/Demo/WebViewController.storyboard b/Demo/WebViewController.storyboard new file mode 100644 index 0000000..62d0c60 --- /dev/null +++ b/Demo/WebViewController.storyboard @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/WebViewController.swift b/Demo/WebViewController.swift new file mode 100644 index 0000000..60bc35b --- /dev/null +++ b/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 private weak var webView: UIWebView! + + override func viewDidLoad() { + super.viewDidLoad() + let req = NSMutableURLRequest(URL: NSURL(string: "http://www.yahoo.co.jp")!, cachePolicy: .ReloadIgnoringCacheData, timeoutInterval: 60) + webView.loadRequest(req) + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + } + + @IBAction func generatePDF() { + do { + let dst = NSHomeDirectory().stringByAppendingString("/sample_tblview.pdf") + try PDFGenerator.generate(webView, outputPath: dst) + openPDFViewer(dst) + } catch let error { + print(error) + } + + } + + private func openPDFViewer(pdfPath: String) { + let url = NSURL(fileURLWithPath: pdfPath) + let storyboard = UIStoryboard(name: "PDFPreviewVC", bundle: nil) + let vc = storyboard.instantiateInitialViewController() as! PDFPreviewVC + vc.setupWithURL(url) + presentViewController(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. + } + */ + +} diff --git a/PDFGenerator.xcodeproj/project.pbxproj b/PDFGenerator.xcodeproj/project.pbxproj index e3880f4..7991f60 100644 --- a/PDFGenerator.xcodeproj/project.pbxproj +++ b/PDFGenerator.xcodeproj/project.pbxproj @@ -30,6 +30,8 @@ 4D900B931C8174B8004034C2 /* SampleTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D900B921C8174B8004034C2 /* SampleTableViewController.swift */; }; 4D900B951C817582004034C2 /* SampleTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D900B941C817582004034C2 /* SampleTableViewCell.swift */; }; 4DC0A7AE1C6C583000E843C8 /* test_image1.png in Resources */ = {isa = PBXBuildFile; fileRef = 4DC0A7AD1C6C583000E843C8 /* test_image1.png */; }; + 4DF6DEB61CA2590900C97F30 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF6DEB51CA2590900C97F30 /* WebViewController.swift */; }; + 4DF6DEB81CA25A5A00C97F30 /* WebViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4DF6DEB71CA25A5A00C97F30 /* WebViewController.storyboard */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -71,6 +73,8 @@ 4D900B921C8174B8004034C2 /* SampleTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleTableViewController.swift; sourceTree = ""; }; 4D900B941C817582004034C2 /* SampleTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleTableViewCell.swift; sourceTree = ""; }; 4DC0A7AD1C6C583000E843C8 /* test_image1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = test_image1.png; sourceTree = ""; }; + 4DF6DEB51CA2590900C97F30 /* WebViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = ""; }; + 4DF6DEB71CA25A5A00C97F30 /* WebViewController.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = WebViewController.storyboard; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -150,6 +154,8 @@ 4D54FFEB1C65CFFD000A9036 /* PDFPreviewVC.swift */, 4D900B921C8174B8004034C2 /* SampleTableViewController.swift */, 4D900B941C817582004034C2 /* SampleTableViewCell.swift */, + 4DF6DEB51CA2590900C97F30 /* WebViewController.swift */, + 4DF6DEB71CA25A5A00C97F30 /* WebViewController.storyboard */, 4D900B901C817444004034C2 /* SampleTableViewController.storyboard */, 4D54FFED1C65D008000A9036 /* PDFPreviewVC.storyboard */, 4D4F97B31C6388AA00108BEB /* Main.storyboard */, @@ -308,6 +314,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4DF6DEB81CA25A5A00C97F30 /* WebViewController.storyboard in Resources */, 4D4F97D31C639CCB00108BEB /* sample_5.jpg in Resources */, 4D4F97BA1C6388AA00108BEB /* LaunchScreen.storyboard in Resources */, 4D4F97CE1C639CCB00108BEB /* sample_0.jpg in Resources */, @@ -348,6 +355,7 @@ buildActionMask = 2147483647; files = ( 4D4F97B21C6388AA00108BEB /* ViewController.swift in Sources */, + 4DF6DEB61CA2590900C97F30 /* WebViewController.swift in Sources */, 4D54FFEC1C65CFFD000A9036 /* PDFPreviewVC.swift in Sources */, 4D900B951C817582004034C2 /* SampleTableViewCell.swift in Sources */, 4D4F97B01C6388AA00108BEB /* AppDelegate.swift in Sources */,