Optimal options to generate PDF preview from excel documents

Hello
We are planning to use Aspose Java (Slides, Cell, and words) to generate pdf previews in realtime.

  • Quality of generated PDF preview vs speed we will go for speed.
  • Quality of generated PDF preview vs memory usage we will go for less memory
  • All file sizes for words, slides and Cell will be less than 10 MB

During our tests we noticed that for certain slide and ppt files the required JVM heap is 8GB and even if the excel file is 1.4MB the generated PDF is 1.6GB in size.

Do you have any recommended setting for the above requirements where we just want to create a pdf preview?

Looking forward to your response.

Regards

Kamran

@Kamran12,

Thanks for your query.

Excel to PDF is one of the reliable features provided by Aspose.Cells APIs. Aspose.Cells would render Excel spreadsheet to PDF file format efficiently and takes lesser memory and CPU usage. Generally, you need 10 times or more memory of the size your template file for PDF conversion but it is not accurate all the time, it might be less or even more depending upon your data/contents, objects or other binary elements used in your template file.

Could you share your template Excel file, we will check your issue soon.

Also, regarding your issue for Powerpoint slides, kindly post your query with artifacts in Aspose.Slides forum, one of my fellow colleagues from Aspose.Slides team will help you there.

Please see attached file. The generated PDF is 1.6 GB and required me to set 8GB heap space.

excellarge.xlsx.zip (978.7 KB)

Here is the code snippet to convert the file. Options to optimize will be helpful

private void cellPreview(InputStream src, OutputStream dst) throws Exception {
Workbook workbook = new Workbook(src);
workbook.save(dst, SaveFormat.PDF);
}

Regards
Kamran

@Kamran12,

Thanks for the template file.

I checked your template file by opening the file into MS Excel and takes the print preview in MS Excel manually and found it has over 250K pages. Just think rendering so many pages (Aspose.Cells would render Excel to PDF pages as the pages are shown when taking print preview of the sheets) would surely takes more time and consume lots of memory. Also the output PDF file’s size would be huge. Please open your template file into Ms Excel manually and save it to PDF file format, you will find that it too consumes lots of time and memory and output file’s size would be large too. I think you should mend your file before taking it as PDF rendering. I see headers text is there all the way to the last column in Ms Excel but your data is only spanning in the range, i.e., A1: U3854. It would be better if you could set the printable area (either manually in MS Excel or by Aspose.Cells APIs) before rendering to PDF file format, it would work fine.
e.g
Sample code:

..........
Worksheet ws1= worksheets.get(0);
PageSetup pageSetup1 = ws1.getPageSetup();
pageSetup1.setPrintArea("A1:U3854");
.........

Thank You Amjad , we will try this.