Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class PDF (val fileName:String){
- import SPDF._
- val document: ValDocument
- def open:PDF = new PDF(fileName) {
- val 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) {
- val document:ValDocument = d 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