I don't say it is impossible, I say it would be hard to do in Java...
I wasn't clear, PDF format is... proprietary, but documented in details. Although learning these details is a daunting task... Fortunately, people have done that already and you should be able to find libraries, some free, others to pay for, allowing you to process it.
I think you can create a PDF layer with Processing and integrate it to an existing document, using iText (shipped with Processing), somebody shown in this forum how to manipulate PDF layers.
That's the "easy" part. If that's all you need, you can get started.
Word (or other Office tools) are another story. To be exact, the early formats of Word were proprietary and, IIRC, not documented. People did reverse engineering to be able to use these documents without having Word. Eg. on Linux systems. These works were used in Open Office, among others.
A more recent format (starting with Word 2000?) is documented and even proposed as a standard: Open XML, not to be confused with Open Document, a concurrent standard (used by OOo).
But, again, it doesn't mean it is simple to manipulate it, so you have to rely on libraries able to do that.