Supposing the PDF form has no comments or annotations, just form fields, you can use a script such as the following to implement the procedure described by David:
var list = new Array();
list = [ //fields to be flattened
"personalInfo",
"notes",
];
var fields = new Array;
for (var i = 0; i < this.numFields; i++) {
fields[i] = [
this.getNthFieldName(i),
this.getField(this.getNthFieldName(i)).display
];
this.getField(fields[i][0]).display = display.noPrint;
}
for (var i = 0; i < list.length; i++) {
this.getField(list[i]).display = display.visible;
}
this.flattenPages({
nStart: 0,
nEnd: this.numPages - 1,
nNonPrint: 1,
});
for (var i = 0; i < this.numFields; i++) {
for (var j = 0; j < fields.length; j++) {
if (fields[j][0] == this.getNthFieldName(i)) {
this.getField(this.getNthFieldName(i)).display = fields[j][1];
}
}
}