Hi Alex,
I remember looking for a way to do this and stumbled upon your post.
I made a small template project to export notes into a single pdf. It contains a shell script and template.
Its probably more complex than what you need, but you can you can adjust to your needs easily, its not a lot of code.
(my version uses #include instead of #import)
You can find it here:
I hope this is helpful!