@@ -364,7 +364,7 @@ public void acroFieldDictionaryNoFields() throws IOException, InterruptedExcepti
364
364
public void regenerateAppearance () throws IOException , InterruptedException {
365
365
String input = "regenerateAppearance.pdf" ;
366
366
String output = "regenerateAppearance.pdf" ;
367
- PdfDocument document = new PdfDocument (new PdfReader (sourceFolder + input ),
367
+ PdfDocument document = new PdfDocument (new PdfReader (sourceFolder + input ),
368
368
new PdfWriter (destinationFolder + output ),
369
369
new StampingProperties ().useAppendMode ());
370
370
PdfAcroForm acro = PdfAcroForm .getAcroForm (document , false );
@@ -379,11 +379,12 @@ public void regenerateAppearance() throws IOException, InterruptedException {
379
379
Assert .assertNull (new CompareTool ().compareByContent (destinationFolder + output ,
380
380
sourceFolder + "cmp_" + output , destinationFolder , "diff" ));
381
381
}
382
+
382
383
@ Test
383
384
public void regenerateAppearance2 () throws IOException , InterruptedException {
384
385
String input = "regenerateAppearance2.pdf" ;
385
386
String output = "regenerateAppearance2.pdf" ;
386
- PdfDocument document = new PdfDocument (new PdfReader (sourceFolder + input ),
387
+ PdfDocument document = new PdfDocument (new PdfReader (sourceFolder + input ),
387
388
new PdfWriter (destinationFolder + output ),
388
389
new StampingProperties ().useAppendMode ());
389
390
PdfAcroForm acro = PdfAcroForm .getAcroForm (document , false );
@@ -394,4 +395,27 @@ public void regenerateAppearance2() throws IOException, InterruptedException {
394
395
Assert .assertNull (new CompareTool ().compareByContent (destinationFolder + output ,
395
396
sourceFolder + "cmp_" + output , destinationFolder , "diff" ));
396
397
}
398
+
399
+ @ Test
400
+ public void flushedPagesTest () throws IOException , InterruptedException {
401
+ String filename = destinationFolder + "flushedPagesTest.pdf" ;
402
+
403
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (filename ));
404
+
405
+ pdfDoc .addNewPage ().flush ();
406
+ pdfDoc .addNewPage ().flush ();
407
+ pdfDoc .addNewPage ();
408
+
409
+ PdfTextFormField field = PdfFormField .createText (pdfDoc , new Rectangle (100 , 100 , 300 , 20 ), "name" , "" );
410
+ PdfAcroForm form = PdfAcroForm .getAcroForm (pdfDoc , true );
411
+ form .addField (field );
412
+
413
+ pdfDoc .close ();
414
+
415
+ CompareTool compareTool = new CompareTool ();
416
+ String errorMessage = compareTool .compareByContent (filename , sourceFolder + "cmp_flushedPagesTest.pdf" , destinationFolder , "diff_" );
417
+ if (errorMessage != null ) {
418
+ Assert .fail (errorMessage );
419
+ }
420
+ }
397
421
}
0 commit comments