@@ -48,7 +48,6 @@ This file is part of the iText (R) project.
48
48
import com .itextpdf .kernel .events .IEventHandler ;
49
49
import com .itextpdf .kernel .events .PdfDocumentEvent ;
50
50
import com .itextpdf .kernel .font .PdfFontFactory ;
51
- import com .itextpdf .kernel .geom .Rectangle ;
52
51
import com .itextpdf .kernel .pdf .canvas .PdfCanvas ;
53
52
import com .itextpdf .kernel .utils .CompareTool ;
54
53
import com .itextpdf .kernel .xmp .XMPException ;
@@ -57,15 +56,17 @@ This file is part of the iText (R) project.
57
56
import com .itextpdf .test .annotations .type .IntegrationTest ;
58
57
import org .junit .Assert ;
59
58
import org .junit .BeforeClass ;
60
- import org .junit .Ignore ;
61
59
import org .junit .Test ;
62
60
import org .junit .experimental .categories .Category ;
63
61
64
62
import java .io .File ;
65
63
import java .io .IOException ;
66
64
import java .util .Calendar ;
67
65
68
- import static org .junit .Assert .*;
66
+ import static org .junit .Assert .assertEquals ;
67
+ import static org .junit .Assert .assertFalse ;
68
+ import static org .junit .Assert .assertNotNull ;
69
+ import static org .junit .Assert .assertTrue ;
69
70
70
71
@ Category (IntegrationTest .class )
71
72
public class PdfStampingTest extends ExtendedITextTest {
@@ -1274,6 +1275,22 @@ public void stampingTestWithFullCompression02() throws IOException, InterruptedE
1274
1275
assertTrue (coef < 0.01 );
1275
1276
}
1276
1277
1278
+ @ Test
1279
+ //TODO: DEVSIX-2007
1280
+ public void stampingStreamNoEndingWhitespace01 () throws IOException , InterruptedException {
1281
+ PdfDocument pdfDocInput = new PdfDocument (new PdfReader (sourceFolder + "stampingStreamNoEndingWhitespace01.pdf" ));
1282
+ PdfDocument pdfDocOutput = new PdfDocument (new PdfWriter (destinationFolder + "stampingStreamNoEndingWhitespace01.pdf" , new WriterProperties ().setCompressionLevel (0 )));
1283
+
1284
+ pdfDocOutput .addEventHandler (PdfDocumentEvent .END_PAGE , new WatermarkEventHandler ());
1285
+
1286
+ pdfDocInput .copyPagesTo (1 , pdfDocInput .getNumberOfPages (), pdfDocOutput );
1287
+
1288
+ pdfDocInput .close ();
1289
+ pdfDocOutput .close ();
1290
+
1291
+ Assert .assertNull (new CompareTool ().compareByContent (destinationFolder + "stampingStreamNoEndingWhitespace01.pdf" , sourceFolder + "cmp_stampingStreamNoEndingWhitespace01.pdf" , destinationFolder , "diff_" ));
1292
+ }
1293
+
1277
1294
static void verifyPdfPagesCount (PdfObject root ) {
1278
1295
if (root .getType () == PdfObject .INDIRECT_REFERENCE )
1279
1296
root = ((PdfIndirectReference ) root ).getRefersTo ();
@@ -1293,35 +1310,20 @@ static void verifyPdfPagesCount(PdfObject root) {
1293
1310
}
1294
1311
}
1295
1312
1296
- @ Test
1297
- //TODO: DEVSIX-2007
1298
- public void stampingStreamNoEndingWhitespace01 () throws IOException , InterruptedException {
1299
- PdfDocument pdfDocInput = new PdfDocument (new PdfReader (sourceFolder + "stampingStreamNoEndingWhitespace01.pdf" ));
1300
- PdfDocument pdfDocOutput = new PdfDocument (new PdfWriter (destinationFolder + "stampingStreamNoEndingWhitespace01.pdf" , new WriterProperties ().setCompressionLevel (0 )));
1301
-
1302
- class WatermarkEventHandler implements IEventHandler {
1303
-
1304
- @ Override
1305
- public void handleEvent (Event event ) {
1306
- PdfDocumentEvent pdfEvent = (PdfDocumentEvent ) event ;
1307
- PdfPage page = pdfEvent .getPage ();
1308
- PdfCanvas pdfCanvas = new PdfCanvas (page );
1309
- try {
1310
- pdfCanvas .beginText ()
1311
- .setFontAndSize (PdfFontFactory .createFont (), 12.0f )
1312
- .showText ("Text" )
1313
- .endText ();
1314
- } catch (IOException e ) {
1315
- }
1313
+ static class WatermarkEventHandler implements IEventHandler {
1314
+
1315
+ @ Override
1316
+ public void handleEvent (Event event ) {
1317
+ PdfDocumentEvent pdfEvent = (PdfDocumentEvent ) event ;
1318
+ PdfPage page = pdfEvent .getPage ();
1319
+ PdfCanvas pdfCanvas = new PdfCanvas (page );
1320
+ try {
1321
+ pdfCanvas .beginText ()
1322
+ .setFontAndSize (PdfFontFactory .createFont (), 12.0f )
1323
+ .showText ("Text" )
1324
+ .endText ();
1325
+ } catch (IOException e ) {
1316
1326
}
1317
1327
}
1318
- pdfDocOutput .addEventHandler (PdfDocumentEvent .END_PAGE , new WatermarkEventHandler ());
1319
-
1320
- pdfDocInput .copyPagesTo (1 , pdfDocInput .getNumberOfPages (), pdfDocOutput );
1321
-
1322
- pdfDocInput .close ();
1323
- pdfDocOutput .close ();
1324
-
1325
- Assert .assertNull (new CompareTool ().compareByContent (destinationFolder + "stampingStreamNoEndingWhitespace01.pdf" , sourceFolder + "cmp_stampingStreamNoEndingWhitespace01.pdf" , destinationFolder , "diff_" ));
1326
1328
}
1327
1329
}
0 commit comments