|
42 | 42 | import org.apache.pdfbox.pdmodel.PDResources; |
43 | 43 | import org.apache.pdfbox.pdmodel.common.PDRectangle; |
44 | 44 | import org.apache.pdfbox.pdmodel.font.PDFont; |
| 45 | +import org.apache.pdfbox.pdmodel.font.PDType0Font; |
45 | 46 | import org.apache.pdfbox.pdmodel.font.PDType1Font; |
46 | 47 | import org.apache.pdfbox.pdmodel.font.Standard14Fonts.FontName; |
47 | 48 | import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation; |
|
53 | 54 | import org.junit.jupiter.api.BeforeEach; |
54 | 55 | import org.junit.jupiter.api.Test; |
55 | 56 | import org.junit.jupiter.api.Assertions; |
| 57 | +import static org.junit.jupiter.api.Assertions.fail; |
56 | 58 |
|
57 | 59 | /** |
58 | 60 | * Test for the PDButton class. |
@@ -120,7 +122,7 @@ void testFlatten() throws IOException |
120 | 122 | if (!TestPDFToImage.doTestFile(file, IN_DIR.getAbsolutePath(), OUT_DIR.getAbsolutePath())) |
121 | 123 | { |
122 | 124 | // don't fail, rendering is different on different systems, result must be viewed manually |
123 | | - System.out.println("Rendering of " + file + " failed or is not identical to expected rendering in " + IN_DIR + " directory"); |
| 125 | + fail("Rendering of " + file + " failed or is not identical to expected rendering in " + IN_DIR + " directory"); |
124 | 126 | } |
125 | 127 |
|
126 | 128 | } |
@@ -154,7 +156,7 @@ void testFlattenWidgetNoRef() throws IOException |
154 | 156 | if (!TestPDFToImage.doTestFile(file, IN_DIR.getAbsolutePath(), OUT_DIR.getAbsolutePath())) |
155 | 157 | { |
156 | 158 | // don't fail, rendering is different on different systems, result must be viewed manually |
157 | | - System.out.println("Rendering of " + file + " failed or is not identical to expected rendering in " + IN_DIR + " directory"); |
| 159 | + fail("Rendering of " + file + " failed or is not identical to expected rendering in " + IN_DIR + " directory"); |
158 | 160 | } |
159 | 161 | } |
160 | 162 |
|
@@ -407,6 +409,33 @@ void testPDFBox3347() throws IOException, URISyntaxException |
407 | 409 | } |
408 | 410 | } |
409 | 411 |
|
| 412 | + /*** |
| 413 | + * PDFBOX-5797: Check that Sejda generated files have their widget /DA entries changed. |
| 414 | + */ |
| 415 | + @Test |
| 416 | + void testPDFBox5797() throws IOException |
| 417 | + { |
| 418 | + try (PDDocument doc = Loader.loadPDF(new File( |
| 419 | + "src/test/resources/org/apache/pdfbox/pdmodel/interactive/annotation/PDFBOX-5797-SO79271803.pdf"))) |
| 420 | + { |
| 421 | + PDType0Font load = PDType0Font.load(doc, |
| 422 | + PDAcroFormFromAnnotsTest.class.getResourceAsStream("/org/apache/pdfbox/resources/ttf/LiberationSans-Regular.ttf"), |
| 423 | + false); |
| 424 | + |
| 425 | + PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm(); |
| 426 | + PDResources resources = acroForm.getDefaultResources(); |
| 427 | + String fontName = resources.add(load).getName(); |
| 428 | + String defaultAppearanceString = "/" + fontName + " 12 Tf 0 g"; |
| 429 | + |
| 430 | + PDTextField myField = (PDTextField) acroForm.getField("Name"); |
| 431 | + myField.setDefaultAppearance(defaultAppearanceString); |
| 432 | + myField.getWidgets().get(0).setAppearance(null); |
| 433 | + myField.setValue("ŞŞ"); // Text with the Ş character made it crash |
| 434 | + |
| 435 | + assertEquals("ŞŞ", myField.getValue()); |
| 436 | + } |
| 437 | + } |
| 438 | + |
410 | 439 | @AfterEach |
411 | 440 | public void tearDown() throws IOException |
412 | 441 | { |
|
0 commit comments