@@ -611,6 +611,27 @@ public virtual void EncryptAes256Pdf2Permissions() {
611
611
CompareEncryptedPdf ( filename ) ;
612
612
}
613
613
614
+ /// <exception cref="System.Exception"/>
615
+ [ NUnit . Framework . Test ]
616
+ public virtual void EncryptWithPasswordAes128NoMetadataCompression ( ) {
617
+ String srcFilename = "srcEncryptWithPasswordAes128NoMetadataCompression.pdf" ;
618
+ PdfReader reader = new PdfReader ( sourceFolder + srcFilename , new ReaderProperties ( ) ) ;
619
+ WriterProperties props = new WriterProperties ( ) . SetStandardEncryption ( "superuser" . GetBytes ( ) , "superowner"
620
+ . GetBytes ( ) , EncryptionConstants . ALLOW_PRINTING , EncryptionConstants . ENCRYPTION_AES_128 | EncryptionConstants
621
+ . DO_NOT_ENCRYPT_METADATA ) ;
622
+ String outFilename = "encryptWithPasswordAes128NoMetadataCompression.pdf" ;
623
+ PdfWriter writer = new PdfWriter ( destinationFolder + outFilename , props ) ;
624
+ PdfDocument pdfDoc = new PdfDocument ( reader , writer ) ;
625
+ pdfDoc . Close ( ) ;
626
+ CompareTool compareTool = new CompareTool ( ) ;
627
+ compareTool . EnableEncryptionCompare ( ) ;
628
+ compareTool . GetOutReaderProperties ( ) . SetPassword ( "superowner" . GetBytes ( ) ) ;
629
+ compareTool . GetCmpReaderProperties ( ) . SetPassword ( "superowner" . GetBytes ( ) ) ;
630
+ String outPdf = destinationFolder + outFilename ;
631
+ String cmpPdf = sourceFolder + "cmp_" + outFilename ;
632
+ NUnit . Framework . Assert . IsNull ( compareTool . CompareByContent ( outPdf , cmpPdf , destinationFolder , "diff_" ) ) ;
633
+ }
634
+
614
635
/// <exception cref="iText.Kernel.XMP.XMPException"/>
615
636
/// <exception cref="System.IO.IOException"/>
616
637
/// <exception cref="System.Exception"/>
0 commit comments