The code for presentation to html file I use -
Presentation pres = new Presentation(new ByteArrayInputStream(content.getBytes()));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
// setting html options
HtmlOptions options = new HtmlOptions();
options.setHtmlFormatter(
HtmlFormatter.createCustomFormatter(new CustomFormattingController()));
INotesCommentsLayoutingOptions inotesOpts = options.getNotesCommentsLayouting();
inotesOpts.setNotesPosition(NotesPositions.BottomFull);
// save the slides to output stream
pres.save(baos, SaveFormat.Html, options);
} finally {
pres.dispose();
baos.close();
}
return ExtractedContent.builder().bytes(baos.toByteArray()).build();
The code I use to convert excel to html -
ByteArrayOutputStream baos = null;
List<byte[]> list = new ArrayList<>();
HtmlSaveOptions options;
try {
Workbook workbook = new Workbook(new ByteArrayInputStream(input.getBytes()));
WorksheetCollection worksheetCollection = workbook.getWorksheets();
worksheetCount = worksheetCollection.getCount();
for (int i = 0; i < worksheetCount; i++) {
baos = new ByteArrayOutputStream();
worksheetCollection.setActiveSheetIndex(i);
options = new HtmlSaveOptions();
options.setExportHeadings(true);
options.setPresentationPreference(true);
options.setEncoding(Encoding.getUTF8());
options.setExportActiveWorksheetOnly(true);
options.setExportGridLines(true);
// save the options into byte array output stream
workbook.save(baos, options);
// add the baos in the list
list.add(baos.toByteArray());
baos.close();
}
} catch (Exception ex) {
log.debug(ex.getMessage());
throw ex;
}
// this will be returned and each baos will be handled as a separate resource.
return ExtractedContent.builder().byteList(list).build();
I want this code to be memory optimised.
Which configurations can I use to lower the memory footprint but not compromise of content quality?
Please suggest.
Can’t find much in the documentations.