In the meantime, I have found a solution to this for myself. The original document is a DOCX. I convert this document to LaTeX using the OSS tool docx2tex. After not finding a solution on the TEX side, I searched on the DOCX side. Using the Python package python-docx, you can read in a DOCX as XML, process it and write it out again. With AI support, I developed a Python script that blends the DOCX. That way it works too, of course.