How to read metadata information from docx documents?

后端 未结 3 1903
执念已碎
执念已碎 2021-01-01 01:46

what I need to achieve is to have a word document template(docx), which will contain Title, Author name, Date, etc.

This template then will be used by users to comp

3条回答
  •  离开以前
    2021-01-01 02:42

    All OpenXML documents have built in core Metadata that will do what you need through System.IO.Packaging. Once you open the word file using the open xml sdk in c#, you can get to these values via the PackageProperties class. There are 11 Properties you can use.

    You "encourage" your user to enter the metadata using Word's Document Information Panel (DIP).

    enter image description here You can force this on by default when they open your template, by a setting in the Developer Toolbar for the template. See the following article on how to set this in your template.

    I wrote a quick Windows Form app that displays this information using open xml sdk call to the PackageProperties of the Word file that is displayed above.

    enter image description here

    Here is the full solution with the sample word file included.

    Hope this helps.

提交回复
热议问题