Hi, any chance CELLSNET-58078 will be ported to Aspose cell for Java ?
We are also encountering xlsx files exported to PDF by Aspose resulted in very large PDF sizes.
Generally, we port enhancements/fixes from .NET to Java with every release to make Aspose.Cells for Java more robust and up-to-date. Could you please try the latest Aspose.Cells for Java 25.4 and let us know your feedback.
hi @amjad.sahi
just tried java 25.4 library. Still experiencing large xlsx converted to PDF in Java.
(140kb xlsx gets converted to 47MB pdf )
Also checked the release note Aspose.Cells for Java 25.4 Release Notes
and there’s no mention of gigantic file conversion fix as in the .net release.
Where can we submit the xlsx file for the dev team to take a look (for Java )
Thanks
It seems you are using different Excel files for the conversion. Anyways, we recommend you to kindly post a new thread/topic in Aspose.Cells category with all the details, sample code and resource files (please zip them prior attaching). We will then check your issue with Aspose.Cells for Java and assist you accordingly in your thread.
@amjad.sahi ,
fyi: I’ve confirmed your fix cuts the runtime and space-complexity (RAM in use) drastically and the resulting PDF file size by roughly 80% down to approx. 11844 KB.
I’m a bit surprised though, that the MinimumSize-option in new Aspose.Cells.PdfSaveOptions { OptimizationType = Aspose.Cells.Rendering.PdfOptimizationType.MinimumSize }
doesn’t change the file size at all (identical to the byte), but the Sha256 differs, when the option is (un)set.
It’s great to hear that the latest version successfully resolved your issue as expected.
You don’t need to set PdfOptimizationType.MinimumSize when using PdfSaveOptions to render to PDF. You can simply save the Excel file directly to PDF.
@M.Heinz ,
I tried OptimizationType = Aspose.Cells.Rendering.PdfOptimizationType.MinimumSize
, the generated pdf file size is reduced to 7944 KB from 11854 KB with Aspose.Cells for .Net 25.4.
Clearly not, what happened on my end, but I’m not to worried about it.
PS C:\Users\m.heinz\Downloads> Get-FileHash .\Anony*
Algorithm Hash Path
--------- ---- ----
SHA256 E1CFFCCBA337D669907268059C4BECF4D84B933553CA8C171879BC21921E6C72 C:\Users\m.heinz\Downloads\Anonymized_Data2.xlsx_minSize.pdf
SHA256 9AE8C586B96545AF0F9AB83E8A91599129CB0E69DADE14D30144E02D48F99E53 C:\Users\m.heinz\Downloads\Anonymized_Data2.xlsx_noOpt.pdf
PS C:\Users\m.heinz\Downloads> Get-ChildItem .\Anony* | % {([int]($_.length)).ToString() + " Bytes - " + $_.Name}
12127644 Bytes - Anonymized_Data2.xlsx_minSize.pdf
12127644 Bytes - Anonymized_Data2.xlsx_noOpt.pdf
That’s how I was converting the Excel file:
AsposeLicenceHelper.SetLicence_Cells();
var path = @"C:\Users\m.heinz\Downloads\";
var inFiles = new List<String> { "Anonymized_Data2.xlsx" };
foreach (var inFile in inFiles)
{
byte[] content = File.ReadAllBytes(path + inFile);
using (MemoryStream stream = new MemoryStream(content))
{
Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(stream);
using (MemoryStream streamToSave = new MemoryStream())
{
var pdfSaveOption = new PdfSaveOptions { /*OptimizationType = Aspose.Cells.Rendering.PdfOptimizationType.MinimumSize*/ };
wb.Save(streamToSave, Aspose.Cells.SaveFormat.Pdf);
content = streamToSave.ToArray();
File.WriteAllBytes(path + inFile + "_noOpt.pdf", content);
}
}
}
Anyways, thanks for the fix.
Thanks for providing further details and code snippet.
We will evaluate for optimization issue regarding PdfOptimizationType.MinimumSize and get back to you soon.
@M.Heinz ,
Please pass the var pdfSaveOption
to wb.Save
method. Then check the results with/without PdfOptimizationType.MinimumSize
.
var pdfSaveOption = new PdfSaveOptions { /*OptimizationType = Aspose.Cells.Rendering.PdfOptimizationType.MinimumSize*/ };
wb.Save(streamToSave, pdfSaveOption);
My bad and sorry for the confusion. Not using the specified options obviously explains the non-existing optimization.
Cheers.
@M.Heinz
Thank you for your feedback. I’m glad you solved the issue with the suggested codes. If you have any questions, please feel free to contact us at any time.