diff --git a/tools/src/test/java/org/apache/pdfbox/tools/TestExtractText.java b/tools/src/test/java/org/apache/pdfbox/tools/TestExtractText.java index 00e169d77bb..1a095710b31 100644 --- a/tools/src/test/java/org/apache/pdfbox/tools/TestExtractText.java +++ b/tools/src/test/java/org/apache/pdfbox/tools/TestExtractText.java @@ -49,6 +49,7 @@ class TestExtractText PrintStream printStream = null; static final String testfile1 = "src/test/resources/org/apache/pdfbox/testPDFPackage.pdf"; static final String testfile2 = "src/test/resources/org/apache/pdfbox/hello3.pdf"; + static final String testfile3 = "src/test/resources/org/apache/pdfbox/AngledExample.pdf"; static String filename1 = null; static String filename2 = null; @@ -243,4 +244,35 @@ void testPDFBoxRepeatableSubcommandAddFileNameOutfileAppend(@TempDir Path tempDi assertTrue(result.contains("PDF file: " + filename2)); } + /** + * Simple test to check that the rotationMagic feature works. + * + * @param tempDir + * @throws Exception + */ + @Test + void testRotationMagic(@TempDir Path tempDir) throws Exception + { + Path path = null; + + try + { + path = tempDir.resolve("outfile.txt"); + Files.deleteIfExists(path); + } + catch (InvalidPathException ipe) + { + System.err.println( + "Error creating temporary test file in " + this.getClass().getSimpleName()); + } + assertNotNull(path); + + PDFBox.main(new String[] { "export:text", "-rotationMagic", "-i", testfile3, + "-o", path.toString() }); + + String result = new String(Files.readAllBytes(path), "UTF-8"); + assertTrue(result.contains("Horizontal Text"), result); + assertTrue(result.contains("Vertical Text"), result); + } + } diff --git a/tools/src/test/resources/org/apache/pdfbox/AngledExample.pdf b/tools/src/test/resources/org/apache/pdfbox/AngledExample.pdf new file mode 100644 index 00000000000..583f0be5cc3 Binary files /dev/null and b/tools/src/test/resources/org/apache/pdfbox/AngledExample.pdf differ