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

Free Support Forum - aspose.com

How to compress images using Aspose.Words for .NET

Hey,

I followed the technique described in a previous post () and for a number of documents it works, however for some documents I get an error:

"Parameter is not valid.

at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at xf9a9481c3f63a419.x3cd5d648729cd9b6.x26b15f27f6076ab7(Image xe058541ca798c059, Stream xcf18e5243f8d5fd3, Int32 x84ac8992b50dcee7)
at xf9a9481c3f63a419.x3cd5d648729cd9b6.x2746a43e49feca2f(Stream xcf18e5243f8d5fd3, Int32 x84ac8992b50dcee7)
at xf9a9481c3f63a419.x3cd5d648729cd9b6.x367bb145e7fa9226(Image xe058541ca798c059, Stream xcf18e5243f8d5fd3)
at x011d489fb9df7027.x8e500baeffc6e539.xdb835d73003565c5(Image xe058541ca798c059)
at Aspose.Words.Drawing.ImageData.SetImage(Image image)
at Kluwer.Common.Word.Compression.Compressor.CompressDocument(Document document) in C:\Projects\Kluwer\JurisoftToKleos\src\Kluwer.Common.Word\Kluwer.Common.Word.Compression\Compressor.cs:line 117"

I attached a word document where I have this error with.

any ideas?

Hi Erik,

Thanks for your query. Please use the latest version of Aspose.Words for .NET. If you still face problem, Please share your document for investigation purposes.

thnx for your reply.

The version I'm using is a download from yesterday so it is brand new.

The document for investigation was already attached in the opening post.

greetings

Erik

Hi Erik,

Thanks for your inquiry.

There is a sample project dedicate to this topic in the samples called CompressImages. Please try using that code and see if it works better. You can download the samples from here:

Thanks,