# Document Properties

> Set the title, author, keywords and user-defined properties of the Document Editor's document from JavaScript, and embed files such as invoice XML in PDF.

- **Product:** TX Text Control .NET Server
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET Server > Document Editor > Document Properties
- **3543 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/properties/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/properties/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/properties/llms-full.txt

---

Title, author, subject and keywords, properties you define yourself and files embedded in PDF documents travel with the document that is open in the Document Editor, and your code reads and sets them. They help you find a document again in a document management system, or attach data such as the XML of an electronic invoice to a PDF document.

The examples extend the view of the [ASP.NET Core](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/document-editor/aspnet-core/llms-full.txt) tutorial. How documents are loaded and saved is described in [Loading and Saving Documents](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/load-save/llms-full.txt).

### What Document Properties Are

Besides its content, a document carries information about itself. [TXTextControl.documentSettings](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/documentsettings-property/llms-full.txt) returns a [DocumentSettings](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/llms-full.txt) object with this information for the document the user is working on:

| Property | Contains | Methods |
|---|---|---|
| Title, author, subject | Strings | [getDocumentTitle](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/getdocumenttitle-method/llms-full.txt), [setDocumentTitle](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/setdocumenttitle-method/llms-full.txt), [getAuthor](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/getauthor-method/llms-full.txt), [setAuthor](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/setauthor-method/llms-full.txt), [getDocumentSubject](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/getdocumentsubject-method/llms-full.txt), [setDocumentSubject](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/setdocumentsubject-method/llms-full.txt) |
| Keywords | An array of strings | [getDocumentKeywords](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/getdocumentkeywords-method/llms-full.txt), [setDocumentKeywords](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/setdocumentkeywords-method/llms-full.txt) |
| Creator application | The application that created the document | [getCreatorApplication](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/getcreatorapplication-method/llms-full.txt), [setCreatorApplication](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/setcreatorapplication-method/llms-full.txt) |
| Creation date | A Unix timestamp | [getCreationDate](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/getcreationdate-method/llms-full.txt), [setCreationDate](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/setcreationdate-method/llms-full.txt) |
| Document base path | A file path used to find resources such as images or hypertext links | [getDocumentBasePath](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/getdocumentbasepath-method/llms-full.txt), [setDocumentBasePath](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/setdocumentbasepath-method/llms-full.txt) |
| User-defined properties | An object with properties you define | [getUserDefinedDocumentProperties](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/getuserdefineddocumentproperties-method/llms-full.txt), [setUserDefinedDocumentProperties](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/setuserdefineddocumentproperties-method/llms-full.txt) |
| Embedded files | Files attached to a PDF document | [embeddedFiles](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/embeddedfiles-property/llms-full.txt) |

The properties are read with get methods, which pass the value to a callback, and changed with set methods. They are stored with the document when it is saved; your code doesn't have to pass them again. `DocumentSettings` was introduced in version 29.0.

### Set and Read Properties

The following code sets the title, author, subject, keywords and two user-defined properties and logs them. Add it below the editor in *Views/Home/Index.cshtml*:

```html
<input type="button" onclick="setProperties()" value="Set Properties" />
<input type="button" onclick="showProperties()" value="Show Properties" />

<script>
    function setProperties() {
        var settings = TXTextControl.documentSettings;

        settings.setDocumentTitle("Quarterly Report");
        settings.setAuthor("Tim Typer");
        settings.setDocumentSubject("Sales figures of the second quarter");
        settings.setDocumentKeywords(["sales", "report", "Q2"]);

        // Replaces all user-defined properties of the document
        settings.setUserDefinedDocumentProperties({
            department: "Sales",
            revision: 3
        });
    }

    function showProperties() {
        var settings = TXTextControl.documentSettings;

        settings.getDocumentTitle(function (title) {
            settings.getAuthor(function (author) {
                settings.getDocumentKeywords(function (keywords) {
                    console.log("Title: " + title);
                    console.log("Author: " + author);
                    // null if the document has no keywords
                    console.log("Keywords: " + (keywords === null ? "none" : keywords.join(", ")));
                });
            });
        });

        settings.getUserDefinedDocumentProperties(function (properties) {
            console.log(properties);
        });
    }
</script>
```

The code works as follows:

- The set methods take the new value. The keywords are an array of strings.
- [setUserDefinedDocumentProperties](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/setuserdefineddocumentproperties-method/llms-full.txt) takes an object whose properties become the user-defined properties of the document. Put property names that contain spaces in quotes, such as `"review status": "open"`.
- `showProperties` nests the get methods, because each passes its value to a callback. [getDocumentKeywords](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/getdocumentkeywords-method/llms-full.txt) passes `null` if the document has no keywords.

Click **Set Properties** and then **Show Properties**: the console shows the values you set.

Because the setter replaces all user-defined properties, read the existing ones first to add a single property:

```javascript
function addProperty(name, value) {
  var settings = TXTextControl.documentSettings;

  settings.getUserDefinedDocumentProperties(function (properties) {
    properties = properties || {}; // no properties yet
    properties[name] = value;
    settings.setUserDefinedDocumentProperties(properties);
  });
}
```

On the server, the same properties are a [UserDefinedPropertyDictionary](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/userdefinedpropertydictionary/llms-full.txt), whose values are strings, Boolean values, integers or doubles and whose names have at most 255 characters. Use these types in the browser as well if the document is processed on the server.

### Read the Properties of a Loaded Document

When your code loads a document with [loadDocument](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/loaddocument-method/llms-full.txt), its callback receives [LoadDocumentCallbackData](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/loaddocumentcallbackdata/llms-full.txt) with some of the properties, such as [author](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/loaddocumentcallbackdata/author-property/llms-full.txt), [documentSubject](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/loaddocumentcallbackdata/documentsubject-property/llms-full.txt), [documentKeywords](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/loaddocumentcallbackdata/documentkeywords-property/llms-full.txt) and [creatorApplication](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/loaddocumentcallbackdata/creatorapplication-property/llms-full.txt):

```javascript
// data contains a base64-encoded DOCX document
function loadAndShowProperties(data) {
  TXTextControl.loadDocument(TXTextControl.StreamType.WordprocessingML, data, function (result) {
    console.log("Author: " + result.author);
    console.log("Subject: " + result.documentSubject);
    console.log("Created by: " + result.creatorApplication);
  });
}
```

The callback data contains neither the title nor the user-defined properties. Read them with `documentSettings` inside the callback, once the document has been loaded.

### Which Formats Store the Properties

- **User-defined properties** are saved and loaded with the TX Text Control format, DOCX and RTF.
- **PDF documents** store the title, author, subject, keywords, creation and modification date and creator application as metadata. [Document Metadata](https://docs.textcontrol.com/tx-text-control-dotnet-server/pdf/metadata/llms-full.txt) covers the metadata of PDF documents on the server.
- **Save settings** override the values of the document when it is saved. The [SaveSettings](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol-savesettings/llms-full.txt) object that [saveDocument](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/savedocument-method/llms-full.txt) takes as its optional third parameter has properties such as [documentTitle](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol-savesettings/documenttitle-property/llms-full.txt), [author](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol-savesettings/author-property/llms-full.txt) and [documentKeywords](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol-savesettings/documentkeywords-property/llms-full.txt).

### Embed Files in PDF Documents

A PDF document can contain other files, for example the XML data of an invoice next to its visual representation. [embeddedFiles](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/documentsettings/embeddedfiles-property/llms-full.txt) returns the [EmbeddedFileCollection](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/embeddedfilecollection/llms-full.txt) of the document. Embedded files are only stored when the document is saved as PDF.

The following code embeds an XML file with a MIME type and a description, and lists the embedded files:

```html
<input type="button" onclick="attachInvoiceData()" value="Attach Invoice Data" />
<input type="button" onclick="listEmbeddedFiles()" value="List Embedded Files" />

<script>
    function attachInvoiceData() {
        var files = TXTextControl.documentSettings.embeddedFiles;
        var xml = "<invoice><number>1001</number><total>249.50</total></invoice>";

        files.addTextFile("invoice.xml", xml, null, function () {
            // Find the new file by its name to complete its settings
            files.forEach(function (file) {
                file.getFileName(function (name) {
                    if (name === "invoice.xml") {
                        file.setMIMEType("application/xml");
                        file.setDescription("Invoice data");
                    }
                });
            });
        });
    }

    function listEmbeddedFiles() {
        TXTextControl.documentSettings.embeddedFiles.forEach(function (file, index, count) {
            file.getFileName(function (name) {
                file.getMIMEType(function (mimeType) {
                    console.log((index + 1) + " of " + count + ": " + name + " (" + mimeType + ")");
                });
            });
        });
    }
</script>
```

- [addTextFile](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/embeddedfilecollection/addtextfile-method/llms-full.txt) takes the file name, the content as a string and optional XMP metadata for the file, which can be `null`. [addBinaryFile](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/embeddedfilecollection/addbinaryfile-method/llms-full.txt) takes the content as a base64-encoded string instead.
- Each [EmbeddedFile](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/embeddedfile/llms-full.txt) has a file name and data that can't be changed, and a description, MIME type and dates that can. Without a MIME type, `application/octet-stream` is used.
- [removeElementAt](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/embeddedfilecollection/removeelementat-method/llms-full.txt) removes a file from the collection by its index.

Save the document with `TXTextControl.StreamType.AdobePDF` to store the files. Electronic invoices such as ZUGFeRD and XRechnung are PDF/A-3 documents, a format the JavaScript `StreamType` doesn't contain: such documents are created on the server, where the relationship of each file ([setRelationship](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/embeddedfile/setrelationship-method/llms-full.txt), for PDF/A only) and its MIME type are required. The blog article [Why Defining MIME Types for PDF/A Attachments Is Essential](https://www.textcontrol.com/blog/2025/12/10/why-defining-mime-types-for-pdfa-attachments-is-essential/) explains why, and [Attachments](https://docs.textcontrol.com/tx-text-control-dotnet-server/pdf/attachments/llms-full.txt) covers attachments on the server.

### Next Steps

- [Loading and Saving Documents](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/load-save/llms-full.txt): save the document with its properties.
- [Document Metadata](https://docs.textcontrol.com/tx-text-control-dotnet-server/pdf/metadata/llms-full.txt): the metadata of PDF documents on the server.
- [Attachments](https://docs.textcontrol.com/tx-text-control-dotnet-server/pdf/attachments/llms-full.txt): embed and extract files in PDF documents on the server.

---

## Nearby

- **Previous:** [Loading and Saving Documents](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/load-save/llms-full.txt)
- **Next:** [Editing Text](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/editing-text/llms-full.txt)
