A PDF that will not open is rarely an empty file. It is a file whose index is wrong, so nothing can find the pages that are still in there.
Repair a PDF →Free every day without an account on some tools. Your file is deleted the moment the job finishes.
The index is rebuilt first. If the file still will not open after that, it is rewritten from whatever can still be parsed, which recovers documents whose contents are damaged as well — slower, and it re-encodes, so it is only used when the first pass was not enough. You are told which happened, and how many pages came back.
A broken index, a truncated download, a file an app closed halfway through writing. The pages are found again and rebuilt into a valid PDF.
Bytes that were never written. If the second half of the file never arrived, the second half of the document is not there to recover.
The repaired file is opened and checked before it is offered to you. If it did not work, it says so instead of handing back something that will not open.