How to add custom hidden attribute values to each paragraph of a docx document content via a Python script?

We have a specific requirement to add some hidden custom attribute values to each paragraph, image, shape, and other elements. Initially, we planned to use UserDefinedAttribute to achieve this. However, we discovered that the values written in this way cannot be parsed by the Aspose library after downloading the document. Are there any other ways to add hidden attribute values?

I think UserDefinedAttribute is specific to ODT. For DOCX, perhaps <w:smartTag> is a good option. See these core.git commits:

These use the UNO API, so you can more or less do the same from a Python script as well.

Could you please provide a Python code example? C language seems a bit difficult for me. Thank you very much!

LibreOffice Developer's Guide: Chapter 6 - Office Development - The Document Foundation Wiki this has some Java samples, if you prefer that.