Hello,
We are using groupdocs-conversion-18.7.jar to convert files to PDF format. Some Excel files are coming through the system with very large print areas (up to 100,000 pages). When the conversion is attempted it is eating up all of the memory on the server and any additional activity results in java.lang.OutOfMemoryError: Java heap space errors. Our service is deployed in Websphere along side other applications. Once GroupDocs starts the conversion it is just churning away at converting the document and eventually the server becomes unresponsive crashing the entire JVM and must be re-booted. What is your recommendation in this situation? How can we error out gracefully from this if the conversion is taking too long or eating up too much memory? Is there anything we can use in the current API to check the properties of the document beforehand? Does the latest version of the API have anything that would help? I can provide a sample file and logs if needed, but would need to send that info privately. Our code is below:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ArrayList<Part> parts = new ArrayList<Part>(request.getParts());
new License().setLicense(ConnectionHandler.class.getClassLoader().getResourceAsStream("GroupDocs.Conversion.lic"));
ConvertedDocument document = null;
InputStream inputStream = parts.get(0).getInputStream();
GroupDocsOutputStream outputStream = new GroupDocsOutputStream(response.getOutputStream());
try {
String filename = parts.get(0).getName();
ConversionConfig conversionConfig = new ConversionConfig();
ConversionHandler conversionHandler = new ConversionHandler(conversionConfig);
PdfSaveOptions saveOptions = new PdfSaveOptions();
EmailOptions emailOptions = saveOptions.getEmailOptions();
emailOptions.setDisplayHeader(true);
emailOptions.setDisplayEmailAddress(false);
emailOptions.setDisplayFromEmailAddress(false);
emailOptions.setDisplayToEmailAddress(false);
emailOptions.setDisplayCcEmailAddress(false);
emailOptions.setDisplayBccEmailAddress(false);
CellsOptions cellsoptions = saveOptions.getCellsOptions();
cellsoptions.setOnePagePerSheet(onePagePerSheet);
cellsoptions.setSkipEmptyRowsAndColumns(skipEmptyRowsAndColumns);
document = conversionHandler.convert(inputStream, filename, saveOptions);
document.save(outputStream);
} catch (Exception e) {
System.out.println("ConvertDocumentToPDF >> Exception reached");
e.printStackTrace();
} finally {
System.out.println("ConvertDocumentToPDF >> Input stream closed");
inputStream.close();
}
}