@@ -42,6 +42,7 @@ source product.
4242*/
4343using System ;
4444using System . IO ;
45+ using System . Text ;
4546using iText . IO . Image ;
4647using iText . IO . Source ;
4748using iText . Kernel . Pdf . Navigation ;
@@ -273,6 +274,31 @@ public virtual void TestFreeReference() {
273274 sourceFolder + "cmp_freeReference.pdf" , destinationFolder , "diff_" ) ) ;
274275 }
275276
277+ /// <exception cref="System.IO.IOException"/>
278+ /// <exception cref="System.Exception"/>
279+ [ NUnit . Framework . Test ]
280+ public virtual void FullCompressionAppendMode ( ) {
281+ PdfWriter writer = new PdfWriter ( destinationFolder + "fullCompressionAppendMode.pdf" , new WriterProperties
282+ ( ) . SetFullCompressionMode ( true ) . SetCompressionLevel ( CompressionConstants . NO_COMPRESSION ) ) ;
283+ PdfDocument pdfDocument = new PdfDocument ( new PdfReader ( sourceFolder + "fullCompressionDoc.pdf" ) , writer ,
284+ new StampingProperties ( ) . UseAppendMode ( ) ) ;
285+ PdfPage page = pdfDocument . GetPage ( 1 ) ;
286+ PdfStream contentStream = new PdfStream ( ) ;
287+ String contentStr = iText . IO . Util . JavaUtil . GetStringForBytes ( pdfDocument . GetPage ( 1 ) . GetFirstContentStream (
288+ ) . GetBytes ( ) , Encoding . ASCII ) ;
289+ contentStream . SetData ( contentStr . Replace ( "/F1 16" , "/F1 24" ) . GetBytes ( Encoding . ASCII ) ) ;
290+ page . GetPdfObject ( ) . Put ( PdfName . Contents , contentStream ) ;
291+ page . SetModified ( ) ;
292+ pdfDocument . Close ( ) ;
293+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( destinationFolder + "fullCompressionAppendMode.pdf"
294+ , sourceFolder + "cmp_fullCompressionAppendMode.pdf" , destinationFolder , "diff_" ) ) ;
295+ PdfDocument assertDoc = new PdfDocument ( new PdfReader ( destinationFolder + "fullCompressionAppendMode.pdf" )
296+ ) ;
297+ NUnit . Framework . Assert . IsTrue ( assertDoc . GetPdfObject ( 9 ) . IsStream ( ) ) ;
298+ NUnit . Framework . Assert . AreEqual ( 1 , ( ( PdfDictionary ) assertDoc . GetPdfObject ( 9 ) ) . GetAsNumber ( PdfName . N ) . IntValue
299+ ( ) ) ;
300+ }
301+
276302 /// <exception cref="System.IO.IOException"/>
277303 /// <exception cref="System.Exception"/>
278304 [ NUnit . Framework . Test ]
0 commit comments