class AcroFormGenerateAppearancesProcessor extends AbstractProcessor
{
    
    private static final Logger LOG = LogManager.getLogger(AcroFormGenerateAppearancesProcessor.class);

    public AcroFormGenerateAppearancesProcessor(PDDocument document)
    { 
        super(document); 
    }

    @Override
    public void process() {<FILL_FUNCTION_BODY>}
}

        /*
         * Get the AcroForm in it's current state.
         *
         * Also note: getAcroForm() applies a default fixup which this processor
         * is part of. So keep the null parameter otherwise this will end
         * in an endless recursive call
         */
        PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm(null);

        if (acroForm != null)
        {            
            try
            {
                LOG.debug("trying to generate appearance streams for fields as NeedAppearances is true()");
                acroForm.refreshAppearances();
                acroForm.setNeedAppearances(false);
            }
            catch (IOException | IllegalArgumentException ex)
            {
                LOG.debug("couldn't generate appearance stream for some fields - check output");
                LOG.debug(ex.getMessage());
            }
        } 
    
<methods><variables>protected final non-sealed org.apache.pdfbox.pdmodel.PDDocument document