0

I am using itextsharp for compressing PDF files, but when I try to compress, it is not compressed as much as I expected (from 4.5 mb to 4.4 mb). Any suggestions as how the compression can be improved?

Here is my code :

string pdfFile = @"c:\Img_Comp\Bigfile.pdf";
        PdfReader reader = new PdfReader(pdfFile);
        PdfStamper stamper = new PdfStamper(reader, new FileStream(@"c:\Img_Comp\Small.pdf", FileMode.CreateNew), PdfWriter.VERSION_1_5);
        stamper.FormFlattening = true;


        stamper.Writer.CompressionLevel = PdfStream.BEST_COMPRESSION; 
        stamper.SetFullCompression();            
        stamper.Close(); 
Ryan Vincent
  • 4,483
  • 7
  • 22
  • 31
  • 2
    If your PDF already contains many compressed items (such as JPEG images), then you're not going to gain much compressing it again. – Phylogenesis Jun 26 '15 at 07:24
  • See [this answer](http://stackoverflow.com/a/22028008/231316) to better understand the setting you are using and why it doesn't do what you think it does. See [this answer](http://stackoverflow.com/a/28723107/231316) along with [this answer](http://stackoverflow.com/a/8751517/231316) for a further explanation on how you could manually implement what you are looking for using iTextSharp. – Chris Haas Jun 26 '15 at 13:07

0 Answers0