plutext / docx4j

JAXB-based Java library for Word docx, Powerpoint pptx, and Excel xlsx files
https://www.docx4java.org/
2.11k stars 1.2k forks source link

Metadata #594

Open EphemearlDusk opened 1 month ago

EphemearlDusk commented 1 month ago

Do we support this feature?

image

https://learn.microsoft.com/en-us/information-protection/develop/concept-mip-metadata

plutext commented 1 month ago

Related to your previous issue https://github.com/plutext/docx4j/issues/583 these end up in docProps/custom.xml

From the test.docx you posted there:

<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
    <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="MSIP_Label_762f7d00-dfe4-4a8e-8651-3fd595918927_Enabled">
        <vt:lpwstr>true</vt:lpwstr>
    </property>
    <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" name="MSIP_Label_762f7d00-dfe4-4a8e-8651-3fd595918927_SetDate">
        <vt:lpwstr>2024-06-27T06:52:38Z</vt:lpwstr>
    </property>
    <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="4" name="MSIP_Label_762f7d00-dfe4-4a8e-8651-3fd595918927_Method">
        <vt:lpwstr>Privileged</vt:lpwstr>
    </property>
    <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="5" name="MSIP_Label_762f7d00-dfe4-4a8e-8651-3fd595918927_Name">
        <vt:lpwstr>Public</vt:lpwstr>
    </property>
    <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="6" name="MSIP_Label_762f7d00-dfe4-4a8e-8651-3fd595918927_SiteId">
        <vt:lpwstr>1e7aeb3b-24a6-4c97-9062-0135644f0526</vt:lpwstr>
    </property>
    <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="7" name="MSIP_Label_762f7d00-dfe4-4a8e-8651-3fd595918927_ActionId">
        <vt:lpwstr>d1a6106a-4f4b-4c8d-8703-cfe0a7317a69</vt:lpwstr>
    </property>
    <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="8" name="MSIP_Label_762f7d00-dfe4-4a8e-8651-3fd595918927_ContentBits">
        <vt:lpwstr>0</vt:lpwstr>
    </property>
</Properties>

So you can work with this stuff by accessing that part directly. wordMLPackage.getDocPropsCustomPart()

You'll need to know what MSIP_Label_GUID to use.