'How to diff PDF files?
Sometimes, when I download a PDF file, such as one of my statements from my bank's website, and then, at a later time, download the same file again, both files differ.
How can I see how they differ?
I've tried:
diff file-1.pdf file-2.pdf
But that just prints:
Binary files file-1.pdf and file-2.pdf differ
Solution 1:[1]
Try:
diff -a file-1.pdf file-2.pdf | less
Or:
git diff -a file-1.pdf file-2.pdf
Example of diff
's output:
1869,1870c1869,1870 < /CreationDate (D:20220504152530-00'00') < /ModDate (D:20220504152530-00'00') --- > /CreationDate (D:20220509154833-00'00') > /ModDate (D:20220509154833-00'00')
Notes:
- For either
diff
orgit-diff
, the-a
,--text
option "treat[s] all files as text". (Seeman diff
orman git-diff
.) - I use
less
in casediff -a
outputs any binary data. (See this question and this comment.) - You must add the
--no-index
option aftergit diff -a
when you run the command in a working tree controlled by Git and both files are inside that working tree. (Seeman git-diff
.) - To view a PDF file's data as text, do
less file.pdf
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |