Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class PDF (val fileName:String){
- import SPDF._
- def document: ValDocument
- // lazy val document = _document
- def open:PDF = new PDF(fileName) {
- def document = documentPDF(fileName)
- }
- lazy val documentInfo = document ∘ (_.getDocumentInformation)
- lazy val documentCatalog = document ∘ (_.getDocumentCatalog)
- lazy val numberOfPages = document ∘ (_.getNumberOfPages)
- lazy val title = documentInfo.toOption ∘ (_.getTitle()) | "Unknow"
- lazy val allPages = documentCatalog ∘ (_.getAllPages())
- def close:PDF = {
- val d = document
- new PDF(fileName) {
- def document:ValDocument = document flatMap closePDF
- }
- }
- def getPage(o:PDOutlineItem):Int =
- document.doOrElse((d) => getPage(o.findDestinationPage(d)))(-1)
- def getPage(p:PDPage):Int = allPages.toOption ∘ (_.indexOf(p)) | -1
- }
Advertisement
Add Comment
Please, Sign In to add comment