@Test public void testShouldDetectRulings() throws IOException { PDDocument pdf_document = PDDocument.load("src/test/resources/technology/tabula/should_detect_rulings.pdf"); ObjectExtractor oe = new ObjectExtractor(pdf_document); PageIterator pi = oe.extract(); while (pi.hasNext()) { assertNotEquals(0, pi.next().getRulings().size()); } }
@Test public void testGoodPassword() throws IOException { PDDocument pdf_document = PDDocument.load("src/test/resources/technology/tabula/encrypted.pdf"); ObjectExtractor oe = new ObjectExtractor(pdf_document, "userpassword"); List<Page> pages = new ArrayList<Page>(); PageIterator pi = oe.extract(); while (pi.hasNext()) { pages.add(pi.next()); } assertEquals(1, pages.size()); }
@Test public void testTextExtractionDoesNotRaise() throws IOException { // PDDocument pdf_document = // PDDocument.load("src/test/resources/technology/tabula/test_text_exception.pdf"); PDDocument pdf_document = PDDocument.load("src/test/resources/technology/tabula/rotated_page.pdf"); ObjectExtractor oe = new ObjectExtractor(pdf_document); PageIterator pi = oe.extract(); while (pi.hasNext()) { System.out.println(pi.next().getText()); // pages.add(pi.next()); } }
@Test public void testCanReadPDFWithOwnerEncryption() throws IOException { PDDocument pdf_document = PDDocument.load("src/test/resources/technology/tabula/S2MNCEbirdisland.pdf"); ObjectExtractor oe = new ObjectExtractor(pdf_document); PageIterator pi = oe.extract(); int i = 0; while (pi.hasNext()) { i++; pi.next(); } assertEquals(2, i); }