         return .slide
     }
     
+    func getScaleFactorForSizeToFit() {
+        let frame = pdfView.frame
+        let aspectRatio = frame.size.width / frame.size.height
+        if portraitScaleFactorForSizeToFit == 0.0 && UIApplication.shared.statusBarOrientation.isPortrait {
+            portraitScaleFactorForSizeToFit = pdfView.scaleFactorForSizeToFit
+            landscapeScaleFactorForSizeToFit = portraitScaleFactorForSizeToFit / aspectRatio            
+            pdfView.minScaleFactor = portraitScaleFactorForSizeToFit
+            pdfView.scaleFactor = portraitScaleFactorForSizeToFit
+        } else if landscapeScaleFactorForSizeToFit == 0.0 && UIApplication.shared.statusBarOrientation.isLandscape {
+            landscapeScaleFactorForSizeToFit = pdfView.scaleFactorForSizeToFit
+            portraitScaleFactorForSizeToFit = landscapeScaleFactorForSizeToFit / aspectRatio
+            pdfView.minScaleFactor = landscapeScaleFactorForSizeToFit
+            pdfView.scaleFactor = landscapeScaleFactorForSizeToFit
+        }
+    }
+    
     func moveToLastReadingProsess() {
         var pageIndex = 0
         if self.userDeaults.object(forKey: (self.pdfView.document?.documentURL?.path)!) != nil {

        self.document?.close(completionHandler: nil)
    }
    
    @IBAction func dismissDocumentViewController() {
        dismiss(animated: true) {
            self.saveAndClose()

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