Esempio n. 1
0
 private static void processPages(PdfFile file, int dpi, int start, int end) {
   try {
     Document document = new Document();
     String staticpath = Play.configuration.getProperty("staticpath", "");
     Logger.debug("process %s", staticpath + file.originalFile);
     document.setFile(staticpath + file.originalFile);
     int numberOfPages = document.getNumberOfPages();
     boolean thumbnail = false;
     if (start < 0 && end < 0) {
       file.numPages = numberOfPages;
       file.save();
       thumbnail = true;
     }
     if (end < 0) {
       end = numberOfPages;
     }
     if (start < 0) {
       start = 0;
     }
     Logger.debug("process %s which has pages %s", file.title, numberOfPages);
     for (int i = start; i < end; i++) {
       processPage(file, document, i, dpi, thumbnail);
     }
   } catch (PDFException e) {
     e.printStackTrace();
   } catch (PDFSecurityException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Esempio n. 2
0
 /**
  * Constructor of this handler. Retrieve the pdfDocument which will contain all the images
  *
  * @param album the pdf album
  */
 public PdfHandler(File album) {
   Logger.getLogger(PdfHandler.class.getName())
       .entering(PdfHandler.class.getName(), "PdfHandler", album);
   pdfDocument = new Document();
   try {
     pdfDocument.setFile(album.getPath());
   } catch (PDFException | PDFSecurityException | IOException ex) {
     Logger.getLogger(PdfHandler.class.getName())
         .log(Level.SEVERE, "Cannot read the PDF document", ex);
     new InfoInterface(InfoInterface.InfoLevel.ERROR, "file-read", album.getName());
   }
   Logger.getLogger(PdfHandler.class.getName()).exiting(PdfHandler.class.getName(), "PdfHandler");
 }