def process(self): self.logger.info('Processing %s', self.filePath) self.logger.info('Calling Pdfinfo') pdfInfo = PdfInfo(self.filePath) self.totalPages = pdfInfo.getPages() self.fileSize = pdfInfo.getFileSizeInBytes() self.logger.info('Total Pages: %d, File Size: %d bytes', self.totalPages, self.fileSize) self.isEncrypted = pdfInfo.isEncrypted() if self.isEncrypted: self.writeStats() raise Exception('Pdf is encrypted. Can\'t do processing.') self.separatePdfPages()
def testEncryptedPdfPages(self): pdfInfo = PdfInfo('tests/sample-scanned-encrypted.pdf') pdfInfo.process() self.assertEqual(pdfInfo.getPages(), 69) self.assertEqual(pdfInfo.getFileSizeInBytes(), 1891519) self.assertEqual(pdfInfo.isEncrypted(), True)
def testPdfPages(self): pdfInfo = PdfInfo('tests/sample.pdf') pdfInfo.process() self.assertEqual(pdfInfo.getPages(), 5) self.assertEqual(pdfInfo.getFileSizeInBytes(), 81691) self.assertEqual(pdfInfo.isEncrypted(), False)