Bug 61562 - [POI][Custom Properties][DOC] Office Warning validation when we add custom properties to ".doc" files
Summary: [POI][Custom Properties][DOC] Office Warning validation when we add custom pr...
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: POIFS (show other bugs)
Version: 3.15-FINAL
Hardware: PC All
: P2 regression (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2017-09-25 14:09 UTC by jonathan.trichereau
Modified: 2017-12-28 20:37 UTC (History)
0 users

Information indicated in Bug Description (555.91 KB, application/zip)
2017-09-25 14:09 UTC, jonathan.trichereau
Document that work with 1000 custom properties (25.50 KB, application/msword)
2017-10-10 16:33 UTC, jonathan.trichereau

Note You need to log in before you can comment on or make changes to this bug.
Description jonathan.trichereau 2017-09-25 14:09:45 UTC
Created attachment 35373 [details]
Information indicated in Bug Description


When addwe add custom properties to a Microsoft Office Word 97 - 2003 document with POI, it works fine. But when we try to open Word document with Office 2007, a warning about Office file validation appears.

If we click on "Open", we can see our custom properties added.

Is there a way to modify code to avoid this message when we open the file in Office ?

We reproduce the issue with POI 3.15, 3.16 and 3.17.

Currently, we use POI 3.10 and we don't have this issue but we need to upgrade POI to resolve other issues in our application.

Also, we passed Office validation tool (BFFValidator) and we have the following results :
- Before modify custom properties, file passed in validator
- After modify custom properties, file failed in validator.

As attachment, you can find in ZIP file :
- Code that we use to reproduce the issue : PbWarningValidationOffice.java
- The original file : beforePOI.doc
- The file modified with custom properties : afterPOI.doc
- XML File returned by Office validation tool when the validation failed : afterPOI.doc.bffvalidator.09-25-17_15-54-22.xml
- Warning when we open file modified in Office : WarningOfficeValidation.jpg

Thanks you for your help.

Best Regards,
Comment 1 Dominik Stadler 2017-10-10 13:03:24 UTC
As far as I see the number of custom properties is mainly limited inside Word here. I.e. your sample works with 50 custom properties, but leads to a corrupt file with 100, the actual limit is somewhere between. 

I could not find anything in the spec detailing what the limit is exactly, though, so it is hard to put in some limits in Apache POI as it seems to be specific to Microsoft Word itself...

Explorer does show 1000 properties fine, so I don't see anything that we can do inside Apache POI for now until there is some specification from Microsoft that explains how many properties are possible for certain types of documents.
Comment 2 jonathan.trichereau 2017-10-10 16:33:57 UTC
Created attachment 35409 [details]
Document that work with 1000 custom properties
Comment 3 jonathan.trichereau 2017-10-10 16:45:52 UTC
Hello Dominik, 

Thanks you for your reply.

For me, it doesn't look like a Word limitation but a issue with POI and NPOIFSFileSystem object: for example, with the document that I put in attachment (afterPOI.doc), if we open this document in Word, we have the Office validation warning. But if we do "save as" on this document in a new file (for example afterPOI2.doc), this file can be open in Word without warning and we have all the custom properties.

Also, if we launch the java program with the file that I added in new attachment (docDoc03.doc), new file can be open without warning and we have all the custom properties.

It seems that the structure of the new Word generated with POI does not necessarily follow the specifications checked in the Office validation module.