When adding custom properties to a MS Word 2000 document, the properties are not displayed within Word nor the Windows Explorer. Custom means the properties displayed on the "Custom" tab in the documents properties. Comparing properties created with MS Word to HPFS with the ReadCustomPropertySets demo results in some differences shown below. HPFS created properties: Property set stream "\DocumentSummaryInformation": (Section 0 does not differ) Section 1: Format ID: 00000000 D5 CD D5 02 2E 9C 10 1B 93 97 08 00 2B 2C F9 AE ............+,.. No. of properties: 3 Property ID: 0, type: 0, value: {2=info} Property ID: 1, type: 2, value: 1252 Property ID: 2, type: 30, value: Hello World MS Word created properties: Property set stream "\DocumentSummaryInformation": Section 1: Format ID: 00000000 D5 CD D5 05 2E 9C 10 1B 93 97 08 00 2B 2C F9 AE ............+,.. No. of properties: 4 Property ID: 0, type: 0, value: {2=info} Property ID: 1, type: 2, value: 65001 Property ID: -2147483648, type: 19, value: [B@b6ece5 Property ID: 2, type: 30, value: Hello World This only occurs if the document has never had any custom properties before. Sample documents can be found under http://www.mathematik.uni-marburg.de/~billen/hpfsSample.zip For more information see the thread "Problem adding custom information to documents" on the POI users mailinglist.
The Format ID of the second section is wrong.
(In reply to comment #1) > The Format ID of the second section is wrong. This ID is created by MS Word. Therefore it should not be wrong. What would be the right ID for that section?
What I meant was that the Format ID of the second section within the DocumentSummaryInformation property set stream in the file edited with HPSF is wrong. I'm not sure exactly how you are using the HPSF API but if you can fix your code to use the correct Format ID for this section I'm sure your trouble will go away.
hmm ... I've set the ID to SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID. I just took a look at the source of org.apache.poi.hpsf.wellknown.SectionIDMap and saw that DOCUMENT_SUMMARY_INFORMATION_ID has the wrong value. I changed DOCUMENT_SUMMARY_INFORMATION_ID[3] to 0x05 and everything worked fine. Thanks for that hint.
I added the format ID of the second DocumentSummaryInformation stream to org.apache.poi.hpsf.wellknown.SectionIDMap in a way that DOCUMENT_SUMMARY_INFORMATION_ID is no longer a byte[] but a byte[][] instead with DOCUMENT_SUMMARY_INFORMATION_ID[0] being the format ID of the first section and DOCUMENT_SUMMARY_INFORMATION_ID[1] being the format ID of the second section. Beware that this is an incompatible change and will break applications that use DOCUMENT_SUMMARY_INFORMATION_ID. All uses of DOCUMENT_SUMMARY_INFORMATION_ID must be replaced my DOCUMENT_SUMMARY_INFORMATION_ID[0]. However, I won't submit this change not right now but together with some more changes I have on my schedule.