I have a book in PDF format and I can't change anything in it with sed
. I can't really use LibreOffice to edit it because it's a 300-page document with lots of images, and my PC would crash during the opening. All I need to do is change one or two characters at only one spot (for example, changing "+2" to "+3", where "+2" has only one occurrence in the entire book) so the solution should be basic.
I uncompressed it and then tried to use sed on it, sed
didn't change anything, although echo $?
would return 0
.
pdftk file.pdf output uncompressed_file.pdf uncompress
sed -i 's/foo/bar/g' uncompressed_file.pdf
pdftk uncompressed_file.pdf output corrected_file.pdf compress
This very code worked with another file, I suspect that some PDF files prevent editing and I'm looking for a way to bypass that.