Skip to content

Commit 5b04a61

Browse files
JonPReillyrnadvodny
authored andcommitted
Add test. DEVSIX-2187
1 parent c8dc9fe commit 5b04a61

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

forms/src/test/java/com/itextpdf/forms/PdfFormCopyTest.java

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,37 @@ public void copyFieldsTest05() throws IOException, InterruptedException {
192192
Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields05.pdf", destinationFolder, "diff_"));
193193
}
194194

195+
196+
@Test
197+
@LogMessages(messages = {
198+
@LogMessage(messageTemplate = LogMessageConstant.DOCUMENT_ALREADY_HAS_FIELD, count = 2)
199+
})
200+
public void copyMultipleSubfieldsTest01() throws IOException, InterruptedException {
201+
String srcFilename = sourceFolder + "copyMultipleSubfieldsTest01.pdf";
202+
String destFilename = destinationFolder + "copyMultipleSubfieldsTest01.pdf";
203+
204+
PdfDocument srcDoc = new PdfDocument(new PdfReader(srcFilename));
205+
PdfDocument destDoc = new PdfDocument(new PdfWriter(destFilename));
206+
207+
PdfPageFormCopier pdfPageFormCopier = new PdfPageFormCopier();
208+
// copying the same page from the same document twice
209+
for (int i = 0; i < 2; ++i) {
210+
srcDoc.copyPagesTo(1, 1, destDoc, pdfPageFormCopier);
211+
}
212+
213+
PdfAcroForm acroForm = PdfAcroForm.getAcroForm(destDoc,false);
214+
215+
acroForm.getField("text_1").setValue("Text 1!");
216+
acroForm.getField("text_2").setValue("Text 2!");
217+
acroForm.getField("text.3").setValue("Text 3!");
218+
acroForm.getField("text.4").setValue("Text 4!");
219+
220+
destDoc.close();
221+
srcDoc.close();
222+
223+
Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyMultipleSubfieldsTest01.pdf", destinationFolder, "diff_"));
224+
}
225+
195226
@Test
196227
@LogMessages(messages = {
197228
@LogMessage(messageTemplate = LogMessageConstant.DOCUMENT_ALREADY_HAS_FIELD, count = 13)
@@ -357,11 +388,10 @@ public void copyFieldsTest12() throws IOException, InterruptedException {
357388
}
358389

359390

360-
361391
@Test
362392
public void copyPagesWithInheritedResources() throws IOException, InterruptedException {
363-
String sourceFile = sourceFolder +"AnnotationSampleStandard.pdf";
364-
String destFile = destinationFolder + "AnnotationSampleStandard_copy.pdf";
393+
String sourceFile = sourceFolder + "AnnotationSampleStandard.pdf";
394+
String destFile = destinationFolder + "AnnotationSampleStandard_copy.pdf";
365395
PdfDocument source = new PdfDocument(new PdfReader(sourceFile));
366396
PdfDocument target = new PdfDocument(new PdfWriter(destFile));
367397
target.initializeOutlines();

0 commit comments

Comments
 (0)