PDFOutputViewController.swift 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // PDFOutputViewController.swift
  3. // PDFGenerator
  4. //
  5. // Created by Suguru Kishimoto on 9/7/16.
  6. //
  7. //
  8. import UIKit
  9. import PDFGenerator
  10. class PDFOutputViewController: UIViewController {
  11. @IBOutlet fileprivate weak var scrollView: UIScrollView!
  12. override func viewDidLoad() {
  13. super.viewDidLoad()
  14. // Do any additional setup after loading the view.
  15. }
  16. override func didReceiveMemoryWarning() {
  17. super.didReceiveMemoryWarning()
  18. // Dispose of any resources that can be recreated.
  19. }
  20. @IBAction func render(_: UIButton) {
  21. let dst = NSHomeDirectory() + "/test.pdf"
  22. try! PDFGenerator.generate(self.scrollView, to: dst)
  23. openPDFViewer(dst)
  24. }
  25. fileprivate func openPDFViewer(_ pdfPath: String) {
  26. let url = URL(fileURLWithPath: pdfPath)
  27. let storyboard = UIStoryboard(name: "PDFPreviewVC", bundle: nil)
  28. let vc = storyboard.instantiateInitialViewController() as! PDFPreviewVC
  29. vc.setupWithURL(url)
  30. present(vc, animated: true, completion: nil)
  31. }
  32. /*
  33. // MARK: - Navigation
  34. // In a storyboard-based application, you will often want to do a little preparation before navigation
  35. override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
  36. // Get the new view controller using segue.destinationViewController.
  37. // Pass the selected object to the new view controller.
  38. }
  39. */
  40. }