Here's some sample code to reproduce the problem:
Basically I'm doing an overlay, closing the resulting document, then doing it again (normally I would make some changes first, but I didn't include that for the sake of brevity).
The last line throws java.io.IOException: Scratch file already closed
If I remove "res.close()" then the code works, but if I do the overlay multiple times, I get warnings like: org.apache.pdfbox.cos.COSDocument - Warning: You did not close a PDF Document
which suggests that I should actually close the document when I'm done with it.