We have a service running on aws cloud. After we introduced aspose pdf for java, the server starts to crash a few times a day. Note that it is evaluation version, so no one really used it. We noticed that, even if no uses the pdf to html conversion function, as long as aspose classes are loaded, crashes will happen. Below is the code which does the conversion (again, the code was not even invoked):
public byte[] convertPDFToFile(byte[] data, int convertToFormat)
{
InputStream in = new ByteArrayInputStream(data);
com.aspose.pdf.Document doc = new com.aspose.pdf.Document(in);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
if (convertToFormat == com.aspose.pdf.SaveFormat.Html)
{
String file = folder + File.separator + data.length + "_" + getCount() + ".html";
com.aspose.pdf.HtmlSaveOptions options = new com.aspose.pdf.HtmlSaveOptions();
options.setDocumentType(com.aspose.pdf.SaveFormat.Html);
options.RasterImagesSavingMode = com.aspose.pdf.HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
//options.FontSavingMode = com.aspose.pdf.HtmlSaveOptions.FontSavingModes.SaveInAllFormats;
options.PartsEmbeddingMode = com.aspose.pdf.HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;
options.LettersPositioningMethod = com.aspose.pdf.LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
//options.setSplitIntoPages(true);// force write HTMLs of all pages into one output document
doc.save(file, options);
try
{
InputStream inp = new FileInputStream(file);
byte[] bytes = IOUtils.toByteArray(inp);
try
{
inp.close();
File f = new File(file);
f.delete();
}
catch (Exception e)
{
log.error("Error deleting file: " + file, e);
}
return bytes;
}
catch (Exception e)
{
log.error("Error reading file: " + file, e);
return "Document failed to convert to html".getBytes();
}
}
else
{
doc.save(outputStream, convertToFormat);
}
return outputStream.toByteArray();
}
Also, we did not notice any exceptions. So not much more information could be provided.
Please help, since this is affecting our production.