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,
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
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,