Products Technologies Demo Docs Blog Support Company

How to Create a Windows Service with TX Text Control

Typically, Microsoft Windows Services are used to create long-running applications that run in the background for non-UI tasks. TX Text Control is used in such Services to create or convert documents in batch processes or to monitor hot folders to start merging processes when new reports are available. In the latest version X10, the non-UI component ServerTextControl is available in client and server editions of TX Text Control. In order to use ServerTextControl in a 100% non-UI environment…

How to Create a Windows Service with TX Text Control
How to use ServerTextControl in Windows Services

Typically, Microsoft Windows Services are used to create long-running applications that run in the background for non-UI tasks. TX Text Control is used in such Services to create or convert documents in batch processes or to monitor hot folders to start merging processes when new reports are available.

In the latest version X10, the non-UI component ServerTextControl is available in client and server editions of TX Text Control. In order to use ServerTextControl in a 100% non-UI environment such as a Windows Service, the server license is required.

The following tutorial shows how to create a Windows Service with TX Text Control X10.

  • Open Visual Studio and create a new Windows Service application.

    Windows Services in Visual Studio
  • Find ServerTextControl in the toolbox and drag and drop an instance to your Service designer.

    Windows Services in Visual Studio
  • Switch to code view of Service1.cs and insert the following code to the OnStart method.

    using (TXTextControl.ServerTextControl tx =
        new TXTextControl.ServerTextControl())
    {
        tx.Create();
        tx.Text = "Hello World.";
        // change directory to a folder
        // where user \'LocalService\' has access to
        tx.Save("c:\results.pdf", TXTextControl.StreamType.AdobePDF);
    }
  • Back in the design view, right-click the surface and choose Add Installer from the context menu.

    Windows Services in Visual Studio
  • In the Properties Window of serviceInstaller1, add a Description, DisplayName and ServiceName that will be later displayed in the Services Management Console.

    Windows Services in Visual Studio
  • In the Properties Window of serviceProcessInstaller1, change the Account to LocalService.

    Windows Services in Visual Studio
  • Compile the Service and run a Developer Command Prompt with explicit administrator rights.

    Change the directory to the output directory of your created Windows Service and type in and execute the following command:

    installutil MyTextControlService.exe
    Windows Services in Visual Studio
  • Open the Services Management Console (Administrative Tools -> Services), find the created Service and click Start.

    Windows Services in Visual Studio

    A PDF document has been created in the folder you defined in your Service code.

TX Text Control provides UI and non-UI components and controls for Windows Forms, WPF, ASP.NET and Windows Service applications. Your code is compatible and can be reused in all of these application types.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Related Posts

Windows FormsGetting StartedTutorial

Windows Forms Tutorial: Create Your First Windows Forms C# Application

This tutorial shows how to create your first Windows Forms application with C# using TX Text Control .NET for Windows Forms in Visual Studio 2022.


ASP.NETASP.NET CoreMailMerge

How to Mail Merge MS Word DOCX Documents in ASP.NET Core C#

Mail merge is the process of merging data, such as Json or IEnumerable objects, into a template document, such as a DOC or DOCX file. This tutorial is a walkthrough of the steps necessary to…


AngularDocument EditorNode.js

Creating an Angular Document Editor Application with a Node.js WebSocket Server

This tutorial shows how to create an Angular application that uses the Document Editor with a Node.js WebSocket server.


ASP.NETASP.NET CoreMailMerge

Adding SVG Watermarks to Documents

This article shows how to add SVG images to document section headers that repeat automatically on each page. This watermark will be inserted vertically and horizontally centered on each section page.


ASP.NETASP.NET CoreMailMerge

Using MailMerge in ASP.NET Core 6 Web Applications

This article shows how to use the TX Text Control ASP.NET MailMerge class to merge templates with JSON data within a .NET 6 application in Visual Studio 2022.