This repository contains a sample plugin for Text Control DS Server that demonstrates how to:
- Implement a controller-based plugin using the
TXTextControl.DocumentServices.Plugin.Abstractionspackage - Register custom middleware
- Read configuration settings
- Register plugin-specific services via dependency injection
- Consume the DS Server DI services
IDocumentProcessingServiceandIDocumentEditorSessionService - Serve a simple HTML configuration page
The sample plugin exposes three groups of examples:
/plugin/helloshows a minimal controller with plugin-owned state and middleware logging/plugin/document-processing/*shows how a plugin controller can useIDocumentProcessingService/plugin/document-editor-sessions/*shows how a plugin controller can work with active editor sessions throughIDocumentEditorSessionService
The sample DocumentProcessingController demonstrates:
- Converting an uploaded base64 document to another DS Server return format
- Retrieving document metadata and merge information
- Generating a barcode image through the barcode sub API
Available endpoints:
POST /plugin/document-processing/convert
POST /plugin/document-processing/getdocumentinfo
GET /plugin/document-processing/createbarcode?text=...
Example request:
POST /plugin/document-processing/convert HTTP/1.1
Content-Type: application/json
{
"document": "<base64 document>",
"returnFormat": "PDF",
"flattenFormFields": true
}The sample DocumentEditorSessionsController demonstrates:
- Resolving a live editor session by
connectionId - Loading a base64 document into the current editor session
- Changing the current paragraph background color in the active selection
- Reading the application field at the current input position
- Saving the current editor session back to a selected document format
Available endpoints:
POST /plugin/document-editor-sessions/loaddocument?connectionId=<id>
POST /plugin/document-editor-sessions/setparagraphbackcolor?connectionId=<id>&color=%23FFF59D
GET /plugin/document-editor-sessions/getcurrentapplicationfield?connectionId=<id>
GET /plugin/document-editor-sessions/savedocument?connectionId=<id>&format=PDF
Example request:
POST /plugin/document-editor-sessions/loaddocument?connectionId=<id> HTTP/1.1
Content-Type: application/json
{
"document": "<base64 document>",
"format": "HTML"
}The plugin also provides a basic web-based configuration page at:
http://<your-ds-server>/plugin-ui/sample-plugin
This page is rendered using MapGet(...) in the plugin's ConfigureMiddleware method, demonstrating how to serve a simple HTML UI from a plugin.
- Build the plugin:
dotnet build- Create a subfolder inside the
Plugins/folder of your DS Server installation (for examplePlugins/SamplePlugin/). - Copy the resulting
TXTextControl.DocumentServices.SamplePlugin.dllinto that subfolder:
Plugins/
└── SamplePlugin/
└── TXTextControl.DocumentServices.SamplePlugin.dll
- Optionally extend your DS Server
appsettings.json:
"SamplePlugin": {
"Greeting": "Hello from the sample plugin!"
}- Restart DS Server.
After deployment, try the minimal sample endpoint:
GET http://<your-ds-server>/plugin/helloThen test the processing and editor-session samples with base64-encoded documents and, for the editor endpoints, a valid DS Server editor connectionId.
HelloPlugin.cs- ImplementsIPlugin, middleware setup and the sample plugin UIControllers/HelloController.cs- Minimal greeting endpointControllers/DocumentProcessingController.cs- Sample usage ofIDocumentProcessingServiceControllers/DocumentEditorSessionsController.cs- Sample usage ofIDocumentEditorSessionServiceServices/GreetingState.cs- Singleton service registered by the pluginTXTextControl.DocumentServices.Plugin.Abstractions/- Reference copy of the public plugin abstractions package
This sample is provided under the MIT License. See LICENSE.md for details.
Text Control DS Server is a powerful on-premise backend for generating, viewing, editing, and signing documents — complete with extensive mail merge and reporting capabilities — accessible via REST APIs or integrated custom logic through plugins like this one. Try it out today and see how it can enhance your document processing workflows!