Bug 52912 - the custom properties write to documents visible from Windows Explorer – but do not display in Office.
Summary: the custom properties write to documents visible from Windows Explorer – but ...
Alias: None
Product: POI
Classification: Unclassified
Component: HPSF (show other bugs)
Version: 3.8-dev
Hardware: PC All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2012-03-15 01:12 UTC by llian
Modified: 2012-03-22 18:06 UTC (History)
0 users

sample document and screen shot related to this issue (220.44 KB, application/x-zip)
2012-03-15 01:12 UTC, llian

Note You need to log in before you can comment on or make changes to this bug.
Description llian 2012-03-15 01:12:20 UTC
Created attachment 28468 [details]
sample document and screen shot related to this issue

When adding custom properties to a Microsoft Office Word 97 - 2003 document, the properties are not displayed within office Word but visible with the Windows Explorer. Custom means the properties displayed on the "Custom" tab in the documents properties.

This used to be working perfectly in poi3.8.beta4. the issue is happening after upgrading to poi3.8.beta5.

Here is the piece of code we are using to adding custom properties,
File doc1 = new File("test.dpc");
		POIFSFileSystem poifs = new POIFSFileSystem(new FileInputStream(doc1));
		DirectoryEntry dir = poifs.getRoot();
		DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
		DocumentEntry dsiEntry = (DocumentEntry) dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);

		DocumentInputStream dis = new DocumentInputStream(siEntry);
		PropertySet ps = new PropertySet(dis);
		SummaryInformation si = new SummaryInformation(ps);
		dis = new DocumentInputStream(dsiEntry);
		ps = new PropertySet(dis);
		DocumentSummaryInformation dsi = new    DocumentSummaryInformation(ps);
		CustomProperties customProperties = dsi.getCustomProperties();
		if (customProperties == null)
			customProperties = new CustomProperties();
		customProperties.put("doc_repo_id", "123456789");

		// Save as our custom properties
		si.write(dir, siEntry.getName());
		dsi.write(dir, dsiEntry.getName());

		File output = new File("C:\\tempoutput.doc");
		OutputStream out = new FileOutputStream(output);

Attached "Test write custom properties.doc", 
"properties invisible from office.PNG" and "properties visible from Windows Explorer.PNG" to show this issue.

Same issue for excel document too refer to "Test write custom properties2.xls".

It seems the issue applies to all Microsoft Office Word 97 - 2003 document only.
We tested Word format docx which is Office 2007 and Office 2010 and it worked.

Read more: http://www.differencebetween.com/difference-between-doc-and-vs-docx-in-microsoft-word/#ixzz1p8xFycgr

This issue is critical because our office component is heavily using custom properties to integrate with other application.
Comment 1 Yegor Kozlov 2012-03-15 08:25:53 UTC
Can you please try with the latest build from trunk? There have been fixes in HPFS recently. 

Comment 2 llian 2012-03-22 18:06:31 UTC
I tried with the latest build from trunk (poi-3.9-beta1) and it worked fine.