Performing template find-and-replace on pages

I'm writing a (clojure) web-app that needs to generate a title page based on a template. I'm trying to follow instructions like these https://dzone.com/articles/create-complex-word-docx, but they seem to be badly out-dated (e.g. I'm getting "P" objects instead of "Text" objects, and have no setContent method available). Can someone tell me what the current method to do this is, or where I can go to find it?