Batch appending PDFs to another PDF

Every month I need to submit a number of PDFs to our health insurance. For that, I need to add a cover page as the first page to each document.
The logic is very simple:

For <each PDF>
Make Copy of Cover Page with Unique Name
Append <each PDF> to Cover Page Copy
End For

Does anyone know how to append a PDF to another PDF?

1 Like
  1. Can you explain more about the content of the cover page?
  2. Are your original file names able to be reused as “unique” file names? If not, what name format to you envisage?
  3. Must the original files remain intact, or can they be updated?
  4. Do you have any third party PDF tools on your Mac, or are we restricted to using native tools?

If you have already resolved all of the above and really just want a way to merge two existing PDFs, you can do that with a bit of Python script

A Python script may very well be easier - for what it’s worth, I also have an Automator script sitting around that takes two PDFs and appends the oldest-created one to the end of the newest one (the old PDF is not deleted). I use it with Hazel to attach the record of paying a bill to the original bill, mostly.

Evidently I can’t quickly upload it here because of the file format, but let me know if it would be useful to you and I can pop it up somewhere else and add a link.

(As well as “Combine PDF Pages” there is also a “Split PDF” action available in Automator which might be useful if you want to go that route. I haven’t experimented with it.)

I’d suggest a Python script as well. I’m no programmer but Python has quite a few libraries devoted to work with PDF that have been rather easy for me to work with and they are pretty well documented. I’ve used pyPDF to do a few things and I found it extremely useful:

https://pyfpdf.readthedocs.io/en/latest/Tutorial/index.html

I need to do something similar to what you describe and would be interested in seeing your Automator script as well as the Hazel script that calls it.

Thanks!

Sorry - this one slipped past me!

I’m travelling at the moment but once I’m home (in the next few weeks) I’ll pull this up and share it.

A brief write-up here - hopefully it helps but let me know if anything is unclear!

1 Like

Thanks so much for posting the details! I will definitely investigate!

1 Like

I believe this link describes the Automator script to merge 2 pdfs.

Yes! Thanks for the additional details!