Is there a definitive way to check an existing PDF for only the header and footer to be populated?
I run a console app that merges existing PDFs together into a single PDF (FileA.pdf, FileB.pdf and FileC.pdf become FileABC.pdf).
The caveat is that I need to check to see if the PDF is empty or populated. If the file is empty, it is ignored from the merge (FileB.pdf is empty so the merged file is FileAC.pdf). However, an empty file still will have a header and footer, just no body content and I need to account for that.
What I do currently is that I manually gather the byte size of all the different empty PDFs, and I use System.IO.FileInfo
to compare if the file size is bigger than the recorded empty size.
While this works 99% of the time, sometimes there is an anomaly and an empty PDF is 1 to 2 bytes higher allowing an empty file slips through.