Author: tilman Date: Sat May 18 14:10:58 2024 New Revision: 1917804 URL: http://svn.apache.org/viewvc?rev=1917804&view=rev Log: PDFBOX-5822: add test for setStartPage and setEndPage
Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Modified: pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java?rev=1917804&r1=1917803&r2=1917804&view=diff ============================================================================== --- pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java (original) +++ pdfbox/branches/3.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Sat May 18 14:10:58 2024 @@ -671,4 +671,24 @@ class TestTextStripper } } + /** + * Check that setting start and end pages work properly. + * + * @throws IOException + */ + @Test + void testStartEndPage() throws IOException + { + File pdfFile = new File("src/test/resources/input", "eu-001.pdf"); + try (PDDocument doc = Loader.loadPDF(pdfFile)) + { + PDFTextStripper textStripper = new PDFTextStripper(); + textStripper.setStartPage(2); + textStripper.setEndPage(2); + String text = textStripper.getText(doc).trim(); + assertTrue(text.startsWith("Pesticides")); + assertTrue(text.endsWith("1 000 10 10")); + assertEquals(text.length(), 1440); + } + } }