diff options
Diffstat (limited to 'pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox')
2 files changed, 59 insertions, 0 deletions
diff --git a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java new file mode 100644 index 00000000..fbe3cdea --- /dev/null +++ b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java @@ -0,0 +1,51 @@ +package at.gv.egiz.pdfas.lib.testpdfbox; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; +import java.util.List; + +import org.apache.pdfbox.pdmodel.PDDocument; +import org.junit.Test; + +import at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder.SignatureFieldsAndPlaceHolderExtractor; +import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData; +import lombok.SneakyThrows; + +public class PDFBoxPlaceholderExtractorTest { + + @Test + @SneakyThrows + public void nextPlaceholder() { + SignaturePlaceholderData result = getNextSignaturePlaceHolder("/data/platzhalter_en_de_test.pdf"); + assertEquals("Im48", result.getPlaceholderName()); + + } + + @Test + @SneakyThrows + public void allPlaceHolders() { + List<String> listOfPlaceHolders = getPlaceHolders("/data/platzhalter_en_de_test.pdf"); + assertNotNull(listOfPlaceHolders); + + } + + private static List<String> getPlaceHolders(String filePath) throws IOException { + final PDDocument doc = PDDocument.load(PDFBoxPlaceholderExtractorTest.class.getResourceAsStream( + filePath)); + final List<String> results = SignatureFieldsAndPlaceHolderExtractor.findEmptySignatureFields(doc); + return results; + + } + + private static SignaturePlaceholderData getNextSignaturePlaceHolder(String filePath) throws IOException { + final PDDocument doc = PDDocument.load(PDFBoxPlaceholderExtractorTest.class.getResourceAsStream( + filePath)); + final SignaturePlaceholderData result = + SignatureFieldsAndPlaceHolderExtractor.getNextUnusedSignaturePlaceHolder(doc); + return result; + + } + +} diff --git a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java index 40522504..0ed05eb5 100644 --- a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java +++ b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java @@ -52,6 +52,14 @@ public class SignatureFieldsAndPlaceHolderExtractorTest { SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("manySignFields.pdf")); Assert.assertEquals(null,result); } + + @Test + public void firstQrCodeOnUnsignedDoc() { + SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("new_qr_2-2.pdf")); + Assert.assertEquals("Image5",result.getPlaceholderName()); + + } + @Test public void subsequentCalls(){ SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("new_qr_2_signed_signed_signed.pdf")); |