We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Compression issue with specific file

Hello,
For this file Compress PDF.pdf (6.8 MB)
, aspose is throwing an exception. It works when we set MaxResolution to 300 instead of 200. Console app to reproduce this issue is attached here.

using System;
using AsposePdfdll = Aspose.Pdf;

namespace CompressPdfIssue
{
    class Program
    {
        static void Main()
        {
            try
            {
                string dataDir = @"C:\Compress PDF.pdf";
                using (AsposePdfdll.Document document = new AsposePdfdll.Document(dataDir))
                {

                    var optimizeOptions = new AsposePdfdll.Optimization.OptimizationOptions();
                    optimizeOptions.RemoveUnusedStreams = true;
                    // Set ImageQuality option
                    optimizeOptions.LinkDuplcateStreams = true;
                    optimizeOptions.RemoveUnusedObjects = true;
                    optimizeOptions.ImageCompressionOptions.CompressImages = true;
                    optimizeOptions.ImageCompressionOptions.ResizeImages = true;
                    optimizeOptions.ImageCompressionOptions.ImageQuality = 20;
                    optimizeOptions.ImageCompressionOptions.MaxResolution = 200;
                    optimizeOptions.ImageCompressionOptions.Version = AsposePdfdll.Optimization.ImageCompressionVersion.Fast;
                    document.OptimizeResources(optimizeOptions);
                    document.Save(@"C:\CompressIssue.pdf");
                }
            }
            catch(Exception ex)
            {
                Console.WriteLine("Issue in compress pdf with Aspose!! "+ ex.Message);
            }
        }
    }
}

@sumitworksimpli

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51687. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.