No internal code to do this, but here is a script to automate Acrobat Professional to do it.
var objShell = new ActiveXObject("shell.application");
var objFolder;
objFolder = objShell.BrowseForFolder(0, "Select the destination folder", 0x10, 0x11);
if (objFolder != null) {
var DestFolder = objFolder.self.path;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var app = pdfe.CreateObject("AcroExch.App");
var baseDoc = pdfe.CreateObject("AcroExch.PDDoc");
var ProgressBar = pdfe.ProgressBar;
ProgressBar.max = pdfe.SelectedFiles.Count;
for (var i = 0; i < pdfe.SelectedFiles.Count; i++) {
try {
FullPathFilename = pdfe.SelectedFiles(i).Filename;
var Filename = FullPathFilename.substr(FullPathFilename.lastIndexOf('\\') + 1);
var DestFullPathFilename = fso.BuildPath(DestFolder, Filename);
if (FullPathFilename == DestFullPathFilename) {
DestFullPathFilename = FullPathFilename.substr(0, FullPathFilename.lastIndexOf('.') - 1) + '_flattened.pdf';
}
pdfe.echo('Flattening: ' + FullPathFilename);
ProgressBar.position = i + 1;
baseDoc.Open(FullPathFilename);
try {
var JSObject = baseDoc.getJSObject();
JSObject.addScript("flatten", "function flatten(){this.flattenPages();}flatten();");
JSObject.removeScript("flatten");
baseDoc.Save(1, DestFullPathFilename);
pdfe.echo(" [OK]", 0, 1);
} catch (err) {
pdfe.echo(err, 0xFF0000);
pdfe.echo("");
}
baseDoc.close();
} catch (err) {
pdfe.echo(err, 0xFF0000);
pdfe.echo("");
}
}
app.Exit();
pdfe.echo('\nDone');
}