PDF Comparison in just 4 lines of code

PDFCompareTrueDiff — A go-to tool for PDF Comparison

Harikrishnan T P
2 min readSep 6, 2022
TRUEDIFF Logo

A python module which helps to compare two PDFs side-by-side.

A python module which helps to compare two PDFs side-by-side.

There are situations when you might need to recognize or confirm the modifications made to a PDF. Finding changes between two documents is an extremely difficult and time-consuming effort. Changes may be overlooked in a document after several rounds of revision. If the documents in question include a lot of information, the comparison procedure might take hours or even days.

Figure 1: Flowchart showing the process stages

PDFCompareTrueDiff is a python module which helps to compare differences between two PDFs. The module compares two PDF files and gives the output as a PNG file showing the side by side comparison. It is simple to perform the comparison because only 4–5 lines of code are required. In case of uneven number of pages TrueDiff additionally produces equalized PDFs from the input pair by appending blank pages at the end.

Figure 2: A screenshot of the final image with highlighted differences

Conclusion

In summary, PDFCompareTrueDiff is a python PDF comparison module which offers a lot of features and even a way to speed up the comparison process with just 4–5 lines of code. It also provides a visual side-by-side comparison so that you can see the differences between the two PDFs.

--

--