Having Performance Issue on Field.setValue of Java PDF API

I am using Aspose PDF Java library to fill the PDF forms in multi-threaded env.
And noticed the performance issue when it first fills the form field.
I have this simple code but the first setValue takes several seconds all the time.
Is there a way to improve the performance?

Form form = pdfDocument.getForm();

        if (form != null) {
            for (Map map : valueData) {
                String fieldName = (String) map.get(fieldKey);
                Object value = map.get(valueKey);
                if (fieldName != null) {
                    Field field = (Field) form.get(fieldName);
                    if ( field != null ) {
                        field.setValue(value == null? "" : value.toString());
                    }
                }
            }
        }

It seems the first call to field.setValue() takes long time, which seems verify license or initialize library or something, every time it runs under new thread.
Is there away to avoid such delays?

@asposejoshua

Would you please share a sample PDF file so that we may try to reproduce and investigate it in our environment. Before sharing requested data, please ensure using Aspose.PDF for Java 19.1.

Hi. Thanks for responding.
It has nothing to do with pdf. So far it happens to all PDF that I tried. (maybe livecycle forms)
I also tried with the latest version. f1120l.pdf (306.4 KB)

It is easily reproduced. I put a logging before calling setValue in a loop.
As show in the below sample, there seems always a longer latency in first call of Field.setValue().
Subsequent calls doesn’t show such delays. In the below logs, first call took 4 about seconds.
I am running this with valid license.

INFO 2019-02-17 21:32:37,671 [main] com.lpl.mule.forms.pdf.PdfUtilAspose: Parsed mapping: {acroField=form1[0].#subform[0].accountno[0], value=99988777}
INFO 2019-02-17 21:32:41,165 [main] com.lpl.mule.forms.pdf.PdfUtilAspose: Parsed mapping: {acroField=form1[0].#subform[0].repid[0], value=AAAA}
INFO 2019-02-17 21:32:41,330 [main] com.lpl.mule.forms.pdf.PdfUtilAspose: Parsed mapping: {acroField=form1[0].#subform[0].ssntaxid[0], value=1234567890}

@asposejoshua

Thank you for the details.

We can not run your code snippet as it includes some undeclared variables like valueData, fieldKey etc. However, please note that Document Object Model (DOM) of Aspose.PDF for Java API is loaded into memory and necessary resource allocation takes place during first iteration. It causes little delay as compared to subsequent conversions for being default behavior of Java.