Performance Improvement during Converting DOCX to PDF for the Second and Third Time using Java

I use Java Aspose Word (use 20.6 but test on last 20.10 too). I try to convert big (I tested on 44 mb file but I think it exists for any files more than 4 mb) docx file. And time of convert is strange for me. I use following code several times (in one main methods):
try {
long t = System.currentTimeMillis();
com.aspose.words.Document doc1 = new com.aspose.words.Document(dataDir + “big_docx.docx”);
com.aspose.words.PdfSaveOptions pdfSaveOpt = new com.aspose.words.PdfSaveOptions();
doc1.save(dataDir+"/out1_.pdf", pdfSaveOpt);
System.out.println(“Time1:”+(System.currentTimeMillis()-t));
} catch (Exception e) {
e.printStackTrace();
}
The time is following: Time1:10976; Time2:7475; Time3:7067
If I convert any other file before these convert (for load classes of Aspose jar) I have following result:
Time1:9679;Time2:7600;Time3:6952

For both case time of second more better then first and time of third better then time of second. Why is it happens and can I do something for decrease time for first time?

p.s. I have like result for draw (without convert) in my application, but it is not so easy for write test example.

Thanks,
Evgeny.

@aleksand,

The first time rendering (to PDF) or printing a Word document takes more time than any subsequent conversions/printings. Aspose.Words needs to pre-cache fonts and other resources for rendering/printing. This only happens for the first time run. If you want to do this pre-caching earlier then you can simply call Document.updatePageLayout method on an empty document before rendering/printing. Also, the conversion times depend on the complexity and number of Pages Word documents have. Can you please ZIP and upload your sample Word document causing the undesired behavior here for testing? We will then investigate the issue further on our end and provide you more information.

P.S. You can also upload the ZIP file to Dropbox and share the Download link here for testing.

It is link to my test docx

I try to check Document.updatePageLayout method but the effect is not very big and no any effect if I alredy converted empty file before.

Thanks,
Evgeny.

@aleksand,

For the sake of any corrections in Aspose.Words for Java API, we have logged this problem in our issue tracking system. The ID of this issue is WORDSJAVA-2484. We will further look into the details of this problem and will keep you updated on the status of linked issue. We apologize for your inconvenience.