View difference between Paste ID: 7TmXmwJb and fiMfptDK
SHOW: | | - or go back to the newest paste.
1
abstract class PDF (val fileName:String){
2
  import SPDF._
3
4-
  val document: ValDocument
4+
  def document: ValDocument
5
//  lazy val document = _document
6
7-
    val document = documentPDF(fileName)
7+
8
    def document = documentPDF(fileName)
9
  }
10-
  lazy val documentInfo    = document              ∘ (_.getDocumentInformation)
10+
11-
  lazy val documentCatalog = document              ∘ (_.getDocumentCatalog)
11+
  lazy val documentInfo = document ∘ (_.getDocumentInformation)
12-
  lazy val numberOfPages   = document              ∘ (_.getNumberOfPages)
12+
  lazy val documentCatalog = document ∘ (_.getDocumentCatalog)
13-
  lazy val title           = documentInfo.toOption ∘ (_.getTitle()) | "Unknow"
13+
  lazy val numberOfPages = document ∘ (_.getNumberOfPages)
14-
  lazy val allPages        = documentCatalog       ∘ (_.getAllPages())
14+
  lazy val title = documentInfo.toOption ∘ (_.getTitle()) | "Unknow"
15
  lazy val allPages = documentCatalog ∘ (_.getAllPages())
16
17
  def close:PDF = {
18
    val d = document
19-
      val document:ValDocument = d flatMap closePDF
19+
20
      def document:ValDocument = document flatMap closePDF
21
    }
22
  }
23
  
24
  def getPage(o:PDOutlineItem):Int =
25
    document.doOrElse((d) => getPage(o.findDestinationPage(d)))(-1)
26
27
  def getPage(p:PDPage):Int = allPages.toOption ∘ (_.indexOf(p)) | -1
28
}