Open the PDF in LibreOffice, choose Tools → Redact. You can then export it within the same menu.
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -sOutputFile=output.pdf input.pdf
You can use the following parameters for -dPDFSETTINGS:
-dPDFSETTINGS=/screen | (screen-view-only quality, 72 dpi images) |
-dPDFSETTINGS=/ebook | (low quality, 150 dpi images) |
-dPDFSETTINGS=/printer | (high quality, 300 dpi images) |
-dPDFSETTINGS=/prepress | (high quality, color preserving, 300 dpi imgs) |
-dPDFSETTINGS=/default | (almost identical to /screen) |