PdfMixFragment implements Closeable { public PDPage nextPage() { if (input.isReverse()) { return handler.getPage(pages.removeLast()); } return handler.getPage(pages.removeFirst()); } private  PdfMixFragment(PdfMixInput input, PDDocumentHandler handler); PDPage nextPage(); boolean hasNextPage(); int getNumberOfPages(); int getStep(); void addLookupEntry(PDPage current, PDPage importPage); void saintizeAnnotations(); @Override void close(); static PdfMixFragment newInstance(PdfMixInput input);  }
@Test public void nextPage() throws TaskIOException, TaskPermissionsException, IOException { try (PdfMixFragment victim = PdfMixFragment.newInstance(new PdfMixInput(PdfStreamSource.newInstanceNoPassword( getClass().getClassLoader().getResourceAsStream("pdf/2_pages.pdf"), "test.pdf")))) { assertTrue(victim.hasNextPage()); assertThat(new PdfTextExtractorByArea() .extractTextFromArea(victim.nextPage(), new Rectangle(54, 56, 60, 21)).trim(), is("First page")); assertTrue(victim.hasNextPage()); assertThat(new PdfTextExtractorByArea() .extractTextFromArea(victim.nextPage(), new Rectangle(54, 56, 60, 21)).trim(), is("Second page")); assertFalse(victim.hasNextPage()); } }