In GIMP, I can import a PDF, and use the GUI to flatten it (if it was made with many layers) by selecting
Flatten Image in the
Image dropdown menu. I can then export the PDF with a new filename.
I would like to automate this. Is there some way to do it via the terminal?