This Java program “flattens” PDF form field data into the PDF content layer using Qoppa’s Java PDF form field library jPDFFields. This means that the field contents will become part of the PDF content and so the document will not be editable anymore.

// Load the document
PDFFields pdfDoc = new PDFFields ("input.pdf", null);            
// Flatten fields
pdfDoc.flattenFields(false, false);           
// Save the document
pdfDoc.saveDocument ("output.pdf");

Download Full Java Sample:
https://www.qoppa.com/files/pdffields/guide/sourcesamples/FlattenFields.java