Search in sources :

Example 1 with PDFDocInfo

use of org.pdfparse.model.PDFDocInfo in project FBReaderJ by geometer.

the class PDFPlugin method readMetainfo.

@Override
public void readMetainfo(AbstractBook book) {
    final ZLFile file = BookUtil.fileByBook(book);
    if (file != file.getPhysicalFile()) {
        // TODO: throw BookReadingException
        System.err.println("Only physical PDF files are supported");
        return;
    }
    try {
        final PDFDocument doc = new PDFDocument(book.getPath());
        // TODO: solution for rc4 encryption
        if (!doc.isEncrypted()) {
            final PDFDocInfo info = doc.getDocumentInfo();
            book.setTitle(info.getTitle());
            book.addAuthor(info.getAuthor());
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : ZLFile(org.geometerplus.zlibrary.core.filesystem.ZLFile) PDFDocument(org.pdfparse.model.PDFDocument) PDFDocInfo(org.pdfparse.model.PDFDocInfo)

Aggregations

ZLFile (org.geometerplus.zlibrary.core.filesystem.ZLFile)1 PDFDocInfo (org.pdfparse.model.PDFDocInfo)1 PDFDocument (org.pdfparse.model.PDFDocument)1