# docx-editor-form-fields

> Word editor loads a form-fields document with fillable form content and spinner loading.

**Framework:** angular  **Component:** DocxEditor  **Variant:** form-fields

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/angular/docx-editor-form-fields.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-angular-documenteditor @syncfusion/ej2-angular-popups
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/docx-editor-form-fields/docx-editor.component.html

```html
<div class="control-section">
    <div>
        <div id="default_title_bar" class="e-de-ctn-title"></div>
        <div style="display:block; height: calc(100vh - 230px);">
            <ejs-documenteditorcontainer #documenteditor_default id="container" [enableToolbar]=true [locale]="culture" [toolbarMode]="'Ribbon'" (created)="onCreate()" [showPropertiesPane]=false
            [documentEditorSettings]="settings" (documentChange)="onDocumentChange()" [serviceUrl]="hostUrl"  height="100%" style="display:block;"  [fileMenuItems]="fileMenuItems" (fileMenuItemClick)="fileMenuItemClick($event)"></ejs-documenteditorcontainer>
        </div>
    </div>
</div>
<style>
@import '../style.css';
#documenteditor_title_contentEditor {
        height: 26px;
        max-width: 75%;
        width: auto;
        overflow: hidden;
        display: inline-block;
        padding-left: 4px;
        padding-right: 4px;
        margin: 5px;
    }

    .single-line {
        cursor: text !important;
        outline: none;
    }

    #default_title_bar {
        height: 36px;
        line-height: 26px;
        width: 100%;
        font-size: 12px;
        padding-left: 15px;
        padding-right: 10px;
        font-family: inherit;
		box-sizing: border-box;
    }

    [class^="e-de-icon-"],
    [class*=" e-de-icon-"] {
        font-family: 'Sample brower icons' !important;
    }

    .e-de-icon-Print:before {
        content: "\e723";
    }

    .e-de-icon-Download:before {
        content: "\e728";
    }

    /** sample level font icons ends*/
</style>
<script>
    window.onbeforeunload = function () {
        return 'Want to save your changes?';
    };    
</script>
```

### src/components/docx-editor-form-fields/docx-editor.component.ts

```typescript
import { Component, ViewEncapsulation, ViewChild } from '@angular/core';
import { ToolbarService, RibbonService, DocumentEditorContainerComponent, LayoutType, DocumentEditorContainerModule, DocumentEditorSettingsModel } from '@syncfusion/ej2-angular-documenteditor';
import { TitleBar } from '../title-bar';
import { formfields, WEB_API_ACTION } from '../datasource/docx-editor-data';
import { isNullOrUndefined } from '@syncfusion/ej2-base';

import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-angular-popups';

/**
 * Document Editor Component
 */
@Component({
    selector: 'control-content',
    templateUrl: 'docx-editor.component.html',
    encapsulation: ViewEncapsulation.None,
    providers: [ToolbarService, RibbonService],
    standalone: true,
    imports: [DocumentEditorContainerModule]
})
export class FormFieldsComponent {
    public hostUrl: string = 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';
    public settings: DocumentEditorSettingsModel = { showRuler: true };
    @ViewChild('documenteditor_default')
    public container!: DocumentEditorContainerComponent;
    public culture: string = 'en-US';
    titleBar!: TitleBar;
    layoutType: LayoutType = "Continuous";

    public fileMenuItems: any = [
        'New',
        'Open',
        {
            text: 'Export',
            id: 'custom_item',
            iconCss: 'e-icons e-export',
            items: [
                { id: 'sfdt', text: 'Syncfusion Document Text (*.sfdt)' },
                { id: 'docx', text: 'Word Document (*.docx)' },
                { id: 'dotx', text: 'Word Template (*.dotx)' },
                { id: 'text', text: 'Plain Text (*.txt)' },
                { id: 'pdf', text: 'PDF (*.pdf)' },
                { id: 'html', text: 'HyperText Markup Language (*.html)' },
                { id: 'rtf', text: 'Rich Text Format (*.rtf)' },
                { id: 'md', text: 'Markdown (*.md)' },
                { id: 'odt', text: 'OpenDocument Text (*.odt)' },
                { id: 'wordml', text: 'Word XML Document (*.xml)' }
            ],
        },
        'Print',
    ];

    public fileMenuItemClick(args: any): void {
        if (args.item.id) {
            let value: string = args.item.id;
            switch (value) {
                case 'docx':
                this.container.documentEditor.save('Sample', 'Docx');
                break;
                case 'sfdt':
                this.container.documentEditor.save('Sample', 'Sfdt');
                break;
                case 'text':
                this.container.documentEditor.save('Sample', 'Txt');
                break;
                case 'dotx':
                this.container.documentEditor.save('Sample', 'Dotx');
                break;
                case 'pdf':
                this.formatSave('Pdf');
                break;
                case 'html':
                this.formatSave('Html');
                break;
                case 'odt':
                this.formatSave('Odt');
                break;
                case 'md':
                this.formatSave('Md');
                break;
                case 'rtf':
                this.formatSave('Rtf');
                break;
                case 'wordml':
                this.formatSave('Xml');
                break;
            }
        }
    }

    public formatSave(type: string): void {
        createSpinner({
            target: document.getElementById('container')!,
        });
        showSpinner(document.getElementById('container')!);
        let format: string = type;
        let url = this.container.documentEditor.serviceUrl + 'Export';
        let http = new XMLHttpRequest();
        http.open('POST', url);
        http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
        http.responseType = 'blob'; // Set the responseType to 'blob' to handle binary data

        // Prepare data to send
        let sfdt = {
            Content: this.container.documentEditor.serialize(),
            Filename: this.container.documentEditor.documentName,
            Format: '.' + format,
        };

        // Set up event listener for the response
        http.onload = () => {
            if (http.status === 200) {
                // Handle the response blob here
                let responseData = http.response;

                // Create a Blob URL for the response data
                let blobUrl = URL.createObjectURL(responseData);

                // Create a link element and trigger the download
                let downloadLink = document.createElement('a');
                downloadLink.href = blobUrl;
                downloadLink.download = this.container.documentEditor.documentName + '.' + format.toLowerCase();
                document.body.appendChild(downloadLink);
                hideSpinner(document.getElementById('container')!);
                downloadLink.click();

                // Cleanup: Remove the link and revoke the Blob URL
                document.body.removeChild(downloadLink);
                URL.revokeObjectURL(blobUrl);
            } else {
                // Handle errors
                console.error('Request failed with status:', http.status);
                hideSpinner(document.getElementById('container')!);
            }
        };

        // Send the request with JSON.stringify(sfdt) as the request body
        http.send(JSON.stringify(sfdt));
    }

    onCreate(): void {
        let titleBarElement: HTMLElement = document.getElementById('default_title_bar')!;
        this.titleBar = new TitleBar(titleBarElement, this.container.documentEditor, true);
        this.container.documentEditor.open(JSON.stringify(formfields));
        this.container.documentEditor.documentName = 'Form Fields';
        this.container.documentEditorSettings.showRuler = true;
        this.titleBar.updateDocumentTitle();
        this.titleBar.showButtons(false);
    }

    onDocumentChange(): void {
        if (!isNullOrUndefined(this.titleBar)) {
            this.titleBar.updateDocumentTitle();
        }
        this.container.documentEditor.focusIn();
    }
}

```
