@@ -192,6 +192,37 @@ public void copyFieldsTest05() throws IOException, InterruptedException {
192
192
Assert .assertNull (new CompareTool ().compareByContent (destFilename , sourceFolder + "cmp_copyFields05.pdf" , destinationFolder , "diff_" ));
193
193
}
194
194
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
+
195
226
@ Test
196
227
@ LogMessages (messages = {
197
228
@ LogMessage (messageTemplate = LogMessageConstant .DOCUMENT_ALREADY_HAS_FIELD , count = 13 )
@@ -357,11 +388,10 @@ public void copyFieldsTest12() throws IOException, InterruptedException {
357
388
}
358
389
359
390
360
-
361
391
@ Test
362
392
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" ;
365
395
PdfDocument source = new PdfDocument (new PdfReader (sourceFile ));
366
396
PdfDocument target = new PdfDocument (new PdfWriter (destFile ));
367
397
target .initializeOutlines ();
0 commit comments