TX Text Control .NET Server

Document Editor Examples

Topic

Half of the online demos of TX Text Control .NET Server show the Document Editor, and many sample projects on GitHub build on it. The demos run in the browser and show their code; the sample projects on GitHub are complete applications for ASP.NET Core, Angular and Blazor that you can clone. For each sample, the table names the TX Text Control version it was written for, because the setup of the editor's backend changed with version 34.0.

Before You Run an Older Sample

Since version 34.0, the TXTextControl.Web.DocumentEditor.Backend package starts the backend process of the editor with the hosted service DocumentEditorWorkerManager. Samples written for earlier versions, and some written for 34.0, reference only TXTextControl.Web and call app.UseTXWebSocketMiddleware() without starting a backend. Add the backend package and register DocumentEditorWorkerManager, as From the Old Document Editor Backend to the Backend Package describes, and update the packages to the current version, as GitHub Examples explains.

Online Demos

Each demo shows its view, controller and JavaScript on the Code tab. All demos run on the current version:

ExampleWhat it showsWhere
ConceptThe Document Editor in an ASP.NET Core view: editing Word documents in the browserConcept
Loading from a viewA document loaded when the view is rendered: DOCX, RTF, HTML, PDF or the TX Text Control formatLoading from View
Loading from a controllerA document that a controller returns and the page loadsLoading from Controller
Loading from JavaScriptA base64-encoded document loaded with the JavaScript APILoading from JavaScript
Server-side loading and savingThe document of an open editor loaded and saved on the server with the WebSocketHandlerLoading from WebSocketHandler
PDF exportThe document exported as PDF, once through a controller and once in JavaScriptExport PDF using Controller, Export PDF JavaScript
Selections and formattingReading and changing the selection and its character formatting with the JavaScript APICharacter Formatting and Selections
StylesFinding, applying and changing paragraph stylesFormatting Styles
TablesInserting and formatting tables and cellsTables
Headers and footersHeaders and footers of a documentHeaders and Footers
Form fieldsCheck boxes, drop-down lists and text form fields, and their export to a fillable PDF formForm Fields, Export Form Fields
Find and replaceThe built-in Find and Replace dialog box, and searching and replacing text from JavaScriptFind and Replace
Table of contentsA table of contents generated from the structure levels of the paragraphs, updated and read as a list of entriesTable of Contents
Form fields and formulasA form whose conditional instructions and table formulas calculate totals from the values users enterForm Fields and Formulas
Track changesReviewing tracked changes and their detailsTrack Changes
CommentsComments compatible with MS WordComments
Document protectionRestricting what users can changeDocument Protection
Spell checkingSpell checking with TX Spell .NETSpell Checking
Signature fieldsSignature fields for signing in the Document Viewer and in PDF documentsSignature Fields
Merge fields by drag and dropA custom sidebar from which users drag merge fields into the templateDrag and Drop Fields
RibbonTabs, groups and buttons of the ribbon changed through the DOM and the JavaScript APIModify the RibbonBar
Rulers and status barThe rulers and the status bar of the editor shown and hiddenCustomize Toolbars
Minimal toolbarThe ribbon replaced by a small toolbarMinimal Editor Toolbar
Error handlingErrors of asynchronous JavaScript API callsAsynchronous Error Handling

The navigation of the demo site lists further demos of formatting, images, sections, charts, barcodes, footnotes, watermarks and more. Demos of template design and merging are listed in Mail Merge Examples.

ASP.NET Core Samples

ExampleWhat it showsWhere
LayoutsFive ways to place the editor in an MVC application: full screen, modal dialog, sidebar, split panel and tabs, as described in 5 Layout Patterns for Integrating the TX Text Control Document Editor in ASP.NET Core C#. .NET 10, version 34.0 with the backend packageTXTextControl.DocumentEditor.Views
Collaboration previewSeveral users in one document, with rooms, sharing links and presence, through the preview package TXTextControl.Web.Collaboration, as described in Introducing TX Text Control Web Collaboration Preview for ASP.NET Core. .NET 10, version 34.0 with the backend packageTXTextControl.Web.Collaboration.TestApp
Document repositoryA file-based document repository with versions, edited in the Document Editor, as described in File Based Document Repository with Version Control in .NET with TX Text Control. .NET 10, version 34.0 with the backend packageTXTextControl.DocumentRepository.Demo
Custom backstageA custom File tab that loads DOCX, RTF, TX and PDF documents through a controller, as described in Build a Custom Backstage View in ASP.NET Core with TX Text Control. Version 34.0, without the backend packageTXTextControl.Web.Backstage
Auto-saveDocuments saved on the server regularly with the WebSocketHandler and a background service, as described in Best Practices: Reliable Auto-Save in TX Text Control Using the WebSocketHandler and Background Services. Version 33.0TXTextControl.Web.Core.Reconnect
Format painterCopying formatting from one selection to another with the JavaScript API, as described in Format Painter in ASP.NET Core: Building Custom Text Formatting with TX Text Control. Version 33.0TXTextControl.Web.JS.FormatPainter
Editor and viewer in one viewEditing a document and previewing the result in the Document Viewer on the same page, as described in ASP.NET Core: Use the Document Editor and Viewer in the Same Razor View. Version 33.0TXTextControl.Web.LivePreview
Document protection by roleUser names, edit modes and editable regions for different roles, as described in Document Protection in ASP.NET with TX Text Control: Healthcare Use Cases. Version 32.0TXTextControl.Web.Core.DocProtectionApp
Contextual toolbarA toolbar that appears for the selected form field, as described in Document Editor: Implementing a Contextual Toolbar. Version 33.0TextControl.Web.MVC.ContextToolbar
Editor in tabsOne editor instance reused in Bootstrap tabs, as described in Reusing TXTextControl Instances in Bootstrap Tabs. Version 33.0TextControl.Web.MVC.Tabs

Angular and Blazor Samples

ExampleWhat it showsWhere
Angular: one editor across routesA persistent editor that moves between routes instead of being created again, as described in Reuse Persistent Document Editor Components in Angular SPA Applications. Angular 19, npm packages of version 33.0TXTextControl.Angular.SPA
Angular: access tokensA security middleware in the backend that checks the access token of the editor, as described in Implementing a Security Middleware for Angular Document Editor Applications in C#. Version 32.0TXTextControl.Angular.Security
Angular: loading and savingDocuments loaded and saved asynchronously through an ASP.NET Core Web API, as described in Asynchronous Loading and Saving in Angular Document Editor with an ASP.NET Core Web API. Version 32.0TXTextControl.Web.Core.Angular.Loading.List
Blazor: editor componentThe DocumentEditor component of TXTextControl.Web.Blazor.DocumentEditor loading and saving documents for a mail merge, as described in TX Text Control for Blazor: Mail Merge Integration Tutorial. Version 33.0TXTextControl.Web.Blazor.MailMerge
Blazor Server with JavaScript interopThe editor in a Blazor Server application on .NET 8 through JavaScript interop instead of the component, as described in Using TX Text Control in a Blazor Server App with .NET 8. Version 32.0TXTextControl.Server.Blazor.DotNet8

Angular and Blazor in the Integration Guide describe the current setup of both frameworks.

React and JavaScript Articles

For React and plain JavaScript, the articles below hold their code in the article itself, without a repository to clone:

ExampleWhat it showsWhere
ReactThe editor in a React application with the React packageUsing the TX Text Control Document Editor in a React Application
React with ASP.NET CoreThe editor in the React and ASP.NET Core template of Visual StudioUsing the Document Editor in an ASP.NET Core React Application
Context menuAdding and removing entries of the context menu with JavaScriptManipulating the Context Menu in the Document Editor using JavaScript
Single-page applicationsRemoving the editor with removeFromDom when a view closesUsing the Document Editor in SPA Applications using the removeFromDom Method
Comments APIWorking with comments in the JavaScript APIComments JavaScript API: Useful Tips and Tricks

React and JavaScript in the Integration Guide describe the current setup.

Next Steps