Back to Devexpress

DocumentProperties Interface

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-5e2bea12.md

latest16.1 KB
Original Source

DocumentProperties Interface

Contains core properties of the document.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public interface DocumentProperties
vb
Public Interface DocumentProperties

The following members return DocumentProperties objects:

Remarks

Core Document Properties are implemented as described in Standard ECMA-376, 1st edition (December 2006) Office Open XML File Formats Part 2 - Open Packaging Conventions clause 10 “Core Properties”.

Use the Document.DocumentProperties property to obtain the DocumentProperties object.

To get an individual document property, access it by name. To display a property in a document, insert an appropriate field.

View Example: Word Processing Document API – How to Process Word Documents in Code

This code snippet demonstrates how to set standard document properties and show them in a document using specific fields. The FieldCollection.Update method updates all property fields in the document body.

Note

If the DOCPROPERTY fields are located in the text box, header or footer, they should be updated separately. Use the Section.BeginUpdateHeader - Section.EndUpdateHeader or Section.BeginUpdateFooter - Section.EndUpdateFooter paired methods to obtain the header or footer. The TextBox.Document property allows you to retrieve the text box content and update the corresponding fields.

csharp
using XtraRichEdit.API.Native;
//...

using (var wordProcessor = new RichEditDocumentServer()) {
    wordProcessor.CreateNewDocument();
    Document document = wordProcessor.Document;
    document.BeginUpdate();

    document.DocumentProperties.Creator = "John Doe";
    document.DocumentProperties.Title = "Inserting Custom Properties";
    document.DocumentProperties.Category = "TestDoc";
    document.DocumentProperties.Description = "This code demonstrates API to modify and display standard document properties.";

    document.Fields.Create(document.AppendText("\nAUTHOR: ").End, "AUTHOR");
    document.Fields.Create(document.AppendText("\nTITLE: ").End, "TITLE");
    document.Fields.Create(document.AppendText("\nCOMMENTS: ").End, "COMMENTS");
    document.Fields.Create(document.AppendText("\nCREATEDATE: ").End, "CREATEDATE");
    document.Fields.Create(document.AppendText("\nCategory: ").End, "DOCPROPERTY Category");
    document.Fields.Update();
    document.EndUpdate();
}
vb
Imports Microsoft.VisualBasic
Imports XtraRichEdit.API.Native
'...

Using wordProcessor = New RichEditDocumentServer()
    wordProcessor.CreateNewDocument()
    Dim document As Document = wordProcessor.Document
    document.BeginUpdate()

    document.DocumentProperties.Creator = "John Doe"
    document.DocumentProperties.Title = "Inserting Custom Properties"
    document.DocumentProperties.Category = "TestDoc"
    document.DocumentProperties.Description = "This code demonstrates API to modify and display standard document properties."

    document.Fields.Create(document.AppendText(vbLf & "AUTHOR: ").End, "AUTHOR")
    document.Fields.Create(document.AppendText(vbLf & "TITLE: ").End, "TITLE")
    document.Fields.Create(document.AppendText(vbLf & "COMMENTS: ").End, "COMMENTS")
    document.Fields.Create(document.AppendText(vbLf & "CREATEDATE: ").End, "CREATEDATE")
    document.Fields.Create(document.AppendText(vbLf & "Category: ").End, "DOCPROPERTY Category")
    document.Fields.Update()
    document.EndUpdate()
End Using

Built-in Properties in Different Formats

The following table lists the built-in document properties supported in different formats:

DOCXDOTXDOCMDOTMRTFDOCDOTWordMLODTHTMLXML
Application
AppVersion
Category
ContentStatus
ContentType
Company
Created
Creator
Description
Identifier
Keywords
Language
LastModifiedBy
LastPrinted
Manager
Modified
Revision
Subject
Template
Title
Version

See Also

DocumentProperties Members

Fields in Rich Text Documents

How to: Retrieve the List of Document Fonts using the Visitor-Iterator Pattern

DevExpress.XtraRichEdit.API.Native Namespace