Search code examples
pdfbox

How to flatten PDF form, while still keep the button intact?


I have flatten pdf form using PDFBOX acroForm.flatten(). but using this method it will remove the button.

I still want the button to work even after I flatten my pdf. This the pdf i want to flatten


Solution

  • Use flatten with parameters:

    public void flatten(List<PDField> fields, boolean refreshAppearances)
    

    this will only flatten the fields you want.