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 2021/10/05 17:14:21 UTC

svn commit: r1893917 - in /pdfbox/trunk/pdfbox/src/test: java/org/apache/pdfbox/pdmodel/interactive/form/ resources/org/apache/pdfbox/pdmodel/interactive/form/

Author: tilman
Date: Tue Oct  5 17:14:21 2021
New Revision: 1893917

URL: http://svn.apache.org/viewvc?rev=1893917&view=rev
Log:
PDFBOX-5287: add test for comb alignment

Added:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/CombAlignmentTest.java   (with props)
    pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/CombTest.pdf   (with props)
    pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/combtest.pdf-1.png   (with props)

Added: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/CombAlignmentTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/CombAlignmentTest.java?rev=1893917&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/CombAlignmentTest.java (added)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/CombAlignmentTest.java Tue Oct  5 17:14:21 2021
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.interactive.form;
+
+import java.io.File;
+import java.io.IOException;
+import org.apache.pdfbox.Loader;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.rendering.TestPDFToImage;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ *
+ * @author Tilman Hausherr
+ */
+public class CombAlignmentTest
+{
+    private static final File OUT_DIR = new File("target/test-output");
+    private static final File IN_DIR = new File("src/test/resources/org/apache/pdfbox/pdmodel/interactive/form");
+    private static final String NAME_OF_PDF = "CombTest.pdf";
+    private static final String TEST_VALUE = "1234567";
+
+    @BeforeEach
+    public void setUp() throws IOException
+    {
+        OUT_DIR.mkdirs();
+    }
+    
+    // PDFBOX-5256
+    @Test
+    void testCombFields() throws IOException
+    {
+        try (PDDocument document = Loader.loadPDF(new File(IN_DIR, NAME_OF_PDF)))
+        {
+            PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm();
+            PDField field = acroForm.getField("PDFBoxCombLeft");
+            field.setValue(TEST_VALUE);
+            field = (PDTextField) acroForm.getField("PDFBoxCombMiddle");
+            field.setValue(TEST_VALUE);
+            field = (PDTextField) acroForm.getField("PDFBoxCombRight");
+            field.setValue(TEST_VALUE);
+            // compare rendering
+            File file = new File(OUT_DIR, NAME_OF_PDF);
+            document.save(file);
+            if (!TestPDFToImage.doTestFile(file, IN_DIR.getAbsolutePath(), OUT_DIR.getAbsolutePath()))
+            {
+                // don't fail, rendering is different on different systems, result must be viewed manually
+                System.err.println("Rendering of " + file +
+                        " failed or is not identical to expected rendering in " + IN_DIR + " directory");
+            }
+        }
+    }
+}

Propchange: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/CombAlignmentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/CombTest.pdf
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/CombTest.pdf?rev=1893917&view=auto
==============================================================================
Binary file - no diff available.

Propchange: pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/CombTest.pdf
------------------------------------------------------------------------------
    svn:mime-type = application/pdf

Added: pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/combtest.pdf-1.png
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/combtest.pdf-1.png?rev=1893917&view=auto
==============================================================================
Binary file - no diff available.

Propchange: pdfbox/trunk/pdfbox/src/test/resources/org/apache/pdfbox/pdmodel/interactive/form/combtest.pdf-1.png
------------------------------------------------------------------------------
    svn:mime-type = image/png