@@ -563,6 +563,28 @@ public void encryptAes256Pdf2Permissions() throws InterruptedException, IOExcept
563
563
compareEncryptedPdf (filename );
564
564
}
565
565
566
+ @ Test
567
+ public void encryptWithPasswordAes128NoMetadataCompression () throws Exception {
568
+ String srcFilename = "srcEncryptWithPasswordAes128NoMetadataCompression.pdf" ;
569
+ PdfReader reader = new PdfReader (sourceFolder + srcFilename , new ReaderProperties ());
570
+ WriterProperties props = new WriterProperties ()
571
+ .setStandardEncryption ("superuser" .getBytes (), "superowner" .getBytes (), EncryptionConstants .ALLOW_PRINTING ,
572
+ EncryptionConstants .ENCRYPTION_AES_128 | EncryptionConstants .DO_NOT_ENCRYPT_METADATA );
573
+ String outFilename = "encryptWithPasswordAes128NoMetadataCompression.pdf" ;
574
+ PdfWriter writer = new PdfWriter (destinationFolder + outFilename , props );
575
+ PdfDocument pdfDoc = new PdfDocument (reader , writer );
576
+ pdfDoc .close ();
577
+
578
+ CompareTool compareTool = new CompareTool ();
579
+ compareTool .enableEncryptionCompare ();
580
+ compareTool .getOutReaderProperties ().setPassword ("superowner" .getBytes ());
581
+ compareTool .getCmpReaderProperties ().setPassword ("superowner" .getBytes ());
582
+ String outPdf = destinationFolder + outFilename ;
583
+ String cmpPdf = sourceFolder + "cmp_" + outFilename ;
584
+ Assert .assertNull (compareTool .compareByContent (outPdf , cmpPdf , destinationFolder , "diff_" ));
585
+ }
586
+
587
+
566
588
public void encryptWithPassword2 (String filename , int encryptionType , int compression ) throws XMPException , IOException , InterruptedException {
567
589
encryptWithPassword2 (filename , encryptionType , compression , false );
568
590
}
0 commit comments