Blog

PDF Collating/Merging

At home I have a wonderful Fujitsu ScanSnap duplex sheet-fed scanner. I can put a stack of double-sided pages into it, and it creates a perfect PDF.

At my office I have an HP all-in-one printer/scanner/copier. It's not quite so nice. It does have a sheet-fed scanner, but it can only do single-sided scans. If I wanted to scan any double-sided documents, I more or less had to take them home and do it there.

I got sick of doing this and decided to write a little Python script that can take two PDF files, and collate/merge them. The first file represents all the odd-numbered pages in the stack of paper, and the second file is the even numbered (i.e. the backs of the odd-numbered pages). My process now is to scan the stack of paper to produce the odd-numbered-pages PDF. Then I flip the stack over and scan again, generating the even-numbered-pages PDF. This PDF is in reverse order (when you flip the stack over, the last page gets scanned first), so my program knows to go backwards through the even-numbered document. I pass these two files to my program and it collates them and outputs a new PDF. The end result is the same as if I had used my ScanSnap at home, just with a little more effort. Better than schleping the documents back and forth from the office every time.

You can find it in all its glory here: https://github.com/parlarjb/PDF-Merge