You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2024/05/18 14:11:02 UTC

svn commit: r1917805 - /pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java

Author: tilman
Date: Sat May 18 14:11:02 2024
New Revision: 1917805

URL: http://svn.apache.org/viewvc?rev=1917805&view=rev
Log:
PDFBOX-5822: add test for setStartPage and setEndPage

Modified:
    pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java

Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java?rev=1917805&r1=1917804&r2=1917805&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java Sat May 18 14:11:02 2024
@@ -724,4 +724,23 @@ public class TestTextStripper extends Te
         String[] arg = {TestTextStripper.class.getName() };
         junit.textui.TestRunner.main( arg );
     }
+
+    /**
+     * Check that setting start and end pages work properly.
+     *
+     * @throws IOException 
+     */
+    public void testStartEndPage() throws IOException
+    {
+        File pdfFile = new File("src/test/resources/input", "eu-001.pdf");
+        PDDocument doc = PDDocument.load(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);
+        doc.close();
+    }
 }