Free Support Forum - aspose.com

PDF Compression does not work

I'm trying to compress a PDF file which is created using Aspose.Cells. because there is no way to compress a PDF when creating in Aspose.Cell, here it was suggested that we first create the PDF and then use Aspose.PDF to reopen the file and implement the Compression.

I've tried doing this in following ways:

PdfContentEditor oEditor = new PdfContentEditor();
oEditor.BindPdf(sSourceFile);
Settings.CompressionLevel = iCompressionLevel;
Settings.SaveMode = SaveMode.Recreate;
oEditor.Save(sCompressedFile);


and


Settings.CompressionLevel = iCompressionLevel;
Settings.SaveMode = SaveMode.Recreate;
PdfFileStamp stamp = new PdfFileStamp(sSourceFile, sCompressedFile);
stamp.Close();


both of these do not seem to work, instead of reducing the size of the output PDF file, they actually increased the size. I've tried different compression levels (3, 5 and 8), and result is same.

Can you please tell me what i'm doing wrong? and what is the right way to do this? a code snippet will be appreciated.


We are using Aspose.Pdf.Kit version 5.8.0.0

Hello Hamed,

Thanks for using our products.

I have tried replicating the scenario at our end but I am afraid I am unable to resolve
Settings class reference. As far as I know, we do not have any class in Aspose.Pdf.Kit API. We are sorry for your inconvenience.

I've this "Settings" class in Aspose.Pdf.Kit library.

If that is not supposed to be used here, can you please suggest the right way to do this? All we need is have a compressed PDF output. Any sample code will be highly appreciated.

Hello Hamed,

Sorry for delay and response.
<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as PDFKITNET-29856. We will investigate this
issue in details and will keep you updated on the status of a correction.<span style=“font-size:10.0pt;
font-family:“Arial”,“sans-serif””>

We apologize for your inconvenience.