@@ -1260,29 +1260,23 @@ public void stampingTestWithTaggedStructure() throws IOException {
1260
1260
1261
1261
@ Test
1262
1262
public void stampingTestWithFullCompression01 () throws IOException , InterruptedException {
1263
- String outPdf = destinationFolder + "stampingTestWithFullCompression01.pdf" ;
1264
- String cmpPdf = sourceFolder + "cmp_stampingTestWithFullCompression01.pdf" ;
1263
+ String compressedOutPdf = destinationFolder + "stampingTestWithFullCompression01Compressed.pdf" ;
1264
+ String decompressedOutPdf = destinationFolder + "stampingTestWithFullCompression01Decompressed.pdf" ;
1265
+
1265
1266
PdfDocument pdfDoc = new PdfDocument (new PdfReader (sourceFolder + "fullCompressedDocument.pdf" ),
1266
- new PdfWriter (outPdf ));
1267
+ new PdfWriter (compressedOutPdf ));
1267
1268
pdfDoc .close ();
1268
- float result = new File (outPdf ).length ();
1269
- float expected = new File (cmpPdf ).length ();
1270
- float coef = Math .abs ((expected - result ) / expected );
1271
- String compareRes = new CompareTool ().compareByContent (outPdf , cmpPdf , destinationFolder );
1272
- assertTrue (coef < 0.01 );
1273
- assertNull (compareRes );
1274
- }
1269
+ float compressedLength = new File (compressedOutPdf ).length ();
1275
1270
1276
- @ Test
1277
- public void stampingTestWithFullCompression02 () throws IOException {
1278
- PdfDocument pdfDoc = new PdfDocument (new PdfReader (sourceFolder + "fullCompressedDocument.pdf" ),
1279
- new PdfWriter (destinationFolder + "stampingTestWithFullCompression02.pdf" ,
1280
- new WriterProperties ().setFullCompressionMode (false )));
1271
+ pdfDoc = new PdfDocument (new PdfReader (sourceFolder + "fullCompressedDocument.pdf" ),
1272
+ new PdfWriter (decompressedOutPdf , new WriterProperties ().setFullCompressionMode (false )));
1281
1273
pdfDoc .close ();
1282
- float result = new File (destinationFolder + "stampingTestWithFullCompression02.pdf" ).length ();
1283
- float expected = new File (sourceFolder + "cmp_stampingTestWithFullCompression02.pdf" ).length ();
1284
- float coef = Math .abs ((expected - result ) / expected );
1285
- assertTrue (coef < 0.01 );
1274
+ float decompressedLength = new File (decompressedOutPdf ).length ();
1275
+
1276
+ float coef = compressedLength / decompressedLength ;
1277
+ String compareRes = new CompareTool ().compareByContent (compressedOutPdf , decompressedOutPdf , destinationFolder );
1278
+ assertTrue (coef < 0.7 );
1279
+ assertNull (compareRes );
1286
1280
}
1287
1281
1288
1282
@ Test
0 commit comments