I regularly get multi-page PDF invoices that need splitting into individual files for my records. I’ve tried a couple basic command line approaches on my Linux setup but they keep failing on the formatting. Any good tool suggestions?
Honestly, the simplest thing to check first is pdfseparate from poppler-utils. I use it on Linux for splitting vendor invoices and it never messes up the formating like some other tools do.
Yeah this is annoying, especially when invoices have inconsistent page breaks. I’m not big on command line stuff myself, I deal with more contract type PDFs, but I’d try Python with a library like pypdf or PyPDF2 since you’re on Linux already, it handles page splitting pretty reliably. Always keep a backup of the original batch before you run any script on it, learned that one the hard way.
I deal with splitting invoice PDFs for our expenses pretty often. pdfseparate from poppler-utils worked well for me on Linux even with messy formatting, tbh I learned the hard way after other tools failed. What distro are you using?
For straightforward page-by-page splitting, I would try qpdf --split-pages input.pdf invoice-%d.pdf; it usually preserves the original page content and layout. pdfseparate is another good option, but if each invoice can span a different number of pages, you will need a small script or a tool that detects invoice numbers or page markers.
I had this same problem with our payroll invoices. I do not know command line tools, but whenever formatting broke, I just opened the file in Chrome and used print. Choosing ‘Save as PDF’ and entering each page number saved the formatting perfectly for me.
@distracted_boomer I second qpdf. I learned the hard way that other tools strip embedded fonts from my client invoices, but qpdf keeps everything looking crisp just like the original design.
@clumsy_goblin i had the same formatting mess with insurance PDFs on my work pc. on windows i just open the file in Chrome and print only the pages i need to a new PDF, layout stays intact. no idea if poppler-utils has a windows build, would try that first.
Are these native PDFs or scanned invoices? If formatting is changing, the command is probably re-rendering pages rather than extracting them unchanged. For tax records I usually open the file in Chrome or Firefox and use Print, select one page at a time, then “Save to PDF”; it was also more reliable than scripts on my old Linux laptop.
First thing I’d check is whether each invoice starts on a predictable page, or if it’s simply one per page. If so, qpdf with a page range handles most runs cleanly on Linux. Keep a backup of the originals before you batch through them.
try using pdftk since its super reliable for splitting batch invoices from the command line. one tip is to use the burst command to easily get every page as its own file. avoid using ghostscript for just splitting because it can mess up the text layour which i learned the hard way.
Fwiw I fought the same battle with CLI splitters wrecking invoice layouts. These days I just run them through PDFcap:
- Upload the multi-page invoice.
- Choose split by every page or set your page ranges.
- Download the separate files, formatting stays intact.
Since invoices have sensitive details, I like that it processes them privately.
@crackedOnyx69 Keeping invoice files private is a sensible consideration. I’d first check whether the PDFs are scanned or native, and whether each invoice has fixed page ranges, since that usually explains why a split workflow changes the layout.