Search code examples
javaasposeaspose.pdf

ASPOSE.PDF very slow on document.save()


I have an issue with ASPOSE.PDF when converting pdf to doc/docx.

    Document pdf2wordDocument = new Document();

While initializing the Document object as soon as my project runs helps ( it reduces the process time with 15-25sec ) the conversion is still very slow.

    pdf2wordDocument = new Document(outputDocDir + fileNameWithExtension); // this takes 15-25 sec - FIXED with initialization of Document object at startup
    String documentExtension = saveOptions.getFormat() == 0 ? "doc" : "docx";

    String outputFile = outputDocDir + fileName + "." + documentExtension;
    log.info("New file to be converted -> " + outputFile + "  Converting...");
    pdf2wordDocument.save(outputFile, saveOptions); // This takes 65-75 seconds
    pdf2wordDocument.close();

I tried both increasing the memory in MEMMIN and MEMMAX and removing the restriction all together – this has no effect on the conversion speed.

Both delays are not present when I compiled a standalone app that only converts the files. However, when implemented in the project there is a huge delay of over a minute for 4-page PDF (the limit of the Trial version of the library)

Does anyone have a clue as how to speed up the pdf2wordDocument.save()?


Solution

  • We accidentally found and fixed the issue with the slow conversion.

    It was a -Djava.compiler=NONE passed into the start script of our project.

    As far as I understand the parameter disables the JIT compiler (enabled by default) which improves performance.

    As per: https://www.ibm.com/docs/en/sdk-java-technology/7.1?topic=compiler-jit-overview

    Disabling the JIT compiler is not recommended except to diagnose or work around JIT compilation problems.