Search code examples
ms-wordapache-poihighlightrestriction

how disable the highlighting of editable regions in word by poi


In Word, when edit restrictions are enabled, the option "Highlight editable areas" is checked by default, and the editable sections will have a light yellow background. How to set edit restrictions enabled but uncheck the "Highlight editable areas"? My project is implemented with POI, and we have not found an interface in POI to uncheck "Highlight editable areas". Is there any other way to achieve this? example here

I do not want the editable sections to be highlighted. How can I achieve this with POI?


Solution

  • This is not possible using Apache POI.

    The setting "Highlight the regions I can edit" is not stored in the *.docx file.

    You can check this by doing the following:

    Open the protected *.docx file having editable areas in Microsoft Word. Deselect the checkbox "Highlight the regions I can edit" in Review tab, in the Protect group, Restrict Editing. Then save the file. Close the file. Reopen the file. You will find the editable regions highlighted again and the checkbox "Highlight the regions I can edit" checked again.

    Thus not checking that setting is only temporarily as long as the file is open in Microsoft Word. It is not stored in the *.docx file.

    Apache POI only writes the *.docx file. It cannot interact with the Word application. Thus settings which cannot be stored in the *.docx file cannot be set using Apache POI.