remove last characters after %EOF (pdf binary file)

Hi,

I want to know how I can remove the last characters of ANY pdf file. I read it under "od" in the command shell to see which were the last characters:
$od corruptedfile.pdf -c

When I see the file, I need to keep only the last characters, or "end of the file": %EOF (obviously keeping all the characters before that one)

any command that would allow me to get rid off them?
Additionally, I would have to make a script for this...
But this is more like a personal issue :slight_smile:

Any ideas? Maybe tail... but I don't know how to keep the X characters from the beginning and eliminate after %EOF

Thanks

one way:

 awk ' /^%EOF/ {print "%EOF"; exit} {print}' filename.pdf > newfilename.pdf

You cannot do anything "inside" od. you could do something inside vim or vi.

1 Like