         self.document?.close(completionHandler: nil)
     }
     
+    @objc func didChangeOrientationHandler() {
+        if portraitScaleFactorForSizeToFit != 0.0 && UIApplication.shared.statusBarOrientation.isPortrait {
+            pdfView.minScaleFactor = portraitScaleFactorForSizeToFit
+            pdfView.scaleFactor = portraitScaleFactorForSizeToFit
+        } else if landscapeScaleFactorForSizeToFit != 0.0 && UIApplication.shared.statusBarOrientation.isLandscape {
+            pdfView.minScaleFactor = landscapeScaleFactorForSizeToFit
+            pdfView.scaleFactor = landscapeScaleFactorForSizeToFit
+        }
+    }
+    
     @IBAction func dismissDocumentViewController() {
         dismiss(animated: true) {
             self.saveAndClose()

        return .slide
    }
    
    func moveToLastReadingProsess() {
        var pageIndex = 0
        if self.userDeaults.object(forKey: (self.pdfView.document?.documentURL?.path)!) != nil {

    var document: Document?
    
    let userDeaults = UserDefaults.standard
    
    var portraitScaleFactorForSizeToFit: CGFloat = 0.0
    var landscapeScaleFactorForSizeToFit: CGFloat = 0.0
    
//    縦書き
    var verticalWriting = false
