This demo iterates over all pages and annotations (by default no form field / widget annotations) and flatten their appearance streams to the pages content stream. The annotations are deleted afterwards.
If the SetaPDF-FormFiller component is installed it will also flatten form fields.