Aspose.PDF lost all the layers after optimize file size

<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;color:#1F497D;
mso-ansi-language:EN-CA;mso-fareast-language:EN-CA;mso-bidi-language:AR-SA”>We
were looking for a 3rd party component to optimize PDF files, which
will work like the “Save as optimized “ function in Adobe Acrobat Pro. In
another words, keep all the layers info but reduce the file size. I tried
Aspose PDF for .NET. Followed this link:

Optimize, Compress or Reduce PDF Size in C#|Aspose.PDF for .NET

<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;color:#1F497D;
mso-ansi-language:EN-CA;mso-fareast-language:EN-CA;mso-bidi-language:AR-SA”>It can reduce the file size but all the layers are lost.
<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;color:#1F497D;
mso-ansi-language:EN-CA;mso-fareast-language:EN-CA;mso-bidi-language:AR-SA”>Attached Test.pdf is the original file. TestOptimized.pdf was generated using Adobe Pro. TestOptimized.pdf is only 642k and it keeps all the layers. Can Aspose.pdf optimize Test.PDF and produce the same result as TestOptimized.pdf?
<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;color:#1F497D;
mso-ansi-language:EN-CA;mso-fareast-language:EN-CA;mso-bidi-language:AR-SA”>
Thanks

Rose
<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;color:#1F497D;
mso-ansi-language:EN-CA;mso-fareast-language:EN-CA;mso-bidi-language:AR-SA”>

Hello Rose,


Thanks for using our API’s.

Please see below sample code for optimization. I have attached the generated output file also. For more details you can visit our documentation link for optimizing the PDF documents.

Optimize PDF Document

C#

string dataDir = “C:/”;
// Open document
Document pdfDocument = new Document(dataDir + “Test.pdf”);
// Optimize for web
pdfDocument.Optimize();
dataDir = dataDir + “OptimizeDocument_out.pdf”;
pdfDocument.Save(dataDir);

Please feel free to contact us for any further assistance.

Best Regards,
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} span.s1 {font-kerning: none}

Thanks for the response.

I tried the “Optimize for web” method. It did not reduce the size at all. For some reasons, it increased the size.

See attached. Test1.pdf is the original file, with file size=5823k, Test1Aspose.pdf was optimized using the code you suggested. It’s size is 5917k.

Thanks

Rose

Hello Rose,


Thanks for sharing further details.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial; -webkit-text-stroke: #000000} span.s1 {font-kerning: none}

I have tested the scenario and have managed to reproduce the problem that optimization is not reducing the size for the PDF document. For the sake of correction, I have logged it as PDFNET-42257 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction.


We are sorry for this inconvenience.


Best Regards,