I've never tried this, so I don't know if this is something that would work.
The only way you can remove content via a script is by running redaction. You would mark the area in the center of the page with a redaction annotation, and then call Doc.applyRedactions() to actually apply them. See here for more information:
Acrobat DC SDK Documentation
Thanks Karl, I was able to find a solution from the documentation you linked to.
Here is how I solved it:
1. Go through each page of the original PDF and delete all content except for the header. You can do this using the Edit tool. AutoHotkey can reduce keystrokes for those interested (you would have to learn the AutoHotkey language which is pretty easy but takes a little time to learn)
2. Go to the Action tool in Acrobat DC and create a new action. Go to "More tools" and click execute JavaScript. Press the right arrow to add that task to the action. Now edit the JavaScript to do the following.
// This script allows you to essentially overlay one PDF over another.
// It's useful when one PDF has some custom header, footer, and/or watermark images/text
// and you want to overlay that to another PDF (Navid - 1/26/2017 02:34:52)
for(count = 0; count < 27; count++){
this.addWatermarkFromFile({
cDIPath: "/R/.../.../.../headers.pdf",
nSourcePage: count, // take Watermark from this page of the source file
nBegin: count, // start applying watermark at this page
nEnd: count, // stop applying watermark at this page
});
}
3. Run the action from the actions list on the right hand side
Note: you will have to change the value of the "count < 27" depending on how many pages are in your PDFs. This script essentially allows you to overlay one PDF on another.