Ghostscript will repair your corrupted PDF automatically… if it can open it in the first place (that is, if it is not damaged beyond repair). But afterwards you’ll still need to double-check the result…
On Linux, try this command:
gs \
-o repaired.pdf \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/prepress \
corrupted.pdf
On Windows, try this one:
gswin32c.exe ^
-o repaired.pdf ^
-sDEVICE=pdfwrite ^
-dPDFSETTINGS=/prepress ^
corrupted.pdf
In case guide can't assist you
https://www.repairtoolbox.com/pdfrepair.html PDF Repair Toolbox