Wrong size when saving

Hello,
I’m opening a file from memory, optimizing it then saving…but what I’ve got is a wrong file size…

if(item != null)
{
byte[] data = item.Content; //suppose 500kb for example

byte[] resultData = null;
using(MemoryStream ms = new MemoryStream(data))
{
using (Aspose.Pdf.Document document = new Aspose.Pdf.Document(ms))
{
document.Optimize();
document.OptimizeResources();

document.Save(“c:\temp\item_” + item.IDProgressivo); //save 405kb

using(MemoryStream msOutput = new MemoryStream())
{
document.Save(msOutput); //<-- here the size is 500KB and not 405KB
resultData = new byte[msOutput.Length];
msOutput.Read(resultData, 0, (int)msOutput.Length);

//

item.NewSize = resultData.Length; //it’s as the old file size
}


}
}

Shouldn’t I get a smaller size after the Optimize/OptimizeResources?

Thanks

p.s. I’m using 7.9.0.0

excuse me , anyone can help me on this?
Thanks

Hi Michele,


Please accept my apologies for delayed response. Can you please share the sample document here? So we test the scenario at our end and provide you more information accordingly.

Sorry for the inconvenience faced

Best Regards,

Hello,
I can’t send you the file…have to look for a file that performs as aswell… I’ve found a problem when for some reason a saving file is bigger then the original… I got a Memory stream is not expandable.
This happens for example with Aspose.Total_NET_Java_Brochure.pdf taken from here
Aspose.Total for .NET and Java Brochure | PDF


pponzano:
I can’t send you the file…have to look for a file that performs as aswell… I’ve found a problem when for some reason a saving file is bigger then the original… I got a Memory stream is not expandable.
This happens for example with Aspose.Total_NET_Java_Brochure.pdf taken from here
Aspose.Total for .NET and Java Brochure | PDF
Hi Michele,

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 PDFNEWNET-35229. We
will investigate this issue in details and will keep you updated on the status
of a correction.<o:p></o:p>

However in order to test the scenario in which resultant file is greater than source PDF document, we would be requiring the source PDF file that you are using. Please note that we use the source PDF files for testing purposes and once the particular issue is resolved, they are removed from our system. For your convenience, I have also marked this forum thread as private and now the resources shared in this thread are only accessible to Aspose staff.

We apologize for your inconvenience.

Hi Michele,


Thanks for your patience.

We have further investigated the problem reported earlier and have observed that the file can not be optimized (at least with optimization methods which are known and supported at the moment). The PDF document can be optimized if it contains unused (“orphaned”) objects, unused resources (for example, image resource which is not used from any page - this situation is often raised when page were extracted from document), or some equal resources which may be “merged” into one object (for example, two images which are shown on more then one page and are stored separately as resources of the pages - this situation may occur when several documents are merged into one document).

However this particular document does not have any of above stated this situations and I am afraid currently it cannot be optimized. Nevertheless, you encounter similar problem while using other PDF files, please share the resource document so that we can further investigate that scenario. We are sorry for this inconvenience.