Products Technologies Demo Docs Blog Support Company

Creating a .NET Console Application with Visual Studio Code and TX Text Control (on Linux)

This article describes how to create a .NET console application using Visual Studio Code and TX Text Control on Linux. It covers installing the .NET SDK, creating a new project, and adding TX Text Control to the project.

Creating a .NET Console Application with Visual Studio Code and TX Text Control (on Linux)

Visual Studio Code (VS Code) is a free, lightweight, open source code editor developed by Microsoft. It supports multiple programming languages, including JavaScript, Python, C#, and many others, and runs on Windows, MacOS, and Linux.

In this tutorial, you will learn how to create a new .NET console application using .NET 8 or later and how to use the ServerTextControl to create a PDF file.

Prerequisites

To follow this tutorial, you need to have the following software installed:

  • Visual Studio Code (VS Code)
  • .NET 8 or later

TX Text Control NuGet Packages

To use TX Text Control, you must have access to the TX Text Control NuGet packages. Currently, you need to install the setup (full or trial) to get the NuGet packages installed locally. The setup is available for Windows only, but the NuGet packages can be copied to your preferred system and hosted in your own NuGet package repository, such as Azure Artifacts.

Use the following link to download your own copy of the TX Text Control trial setup.

Download Trial

Create a new .NET console application

To create a new .NET console application, follow these steps:

  1. Open Visual Studio Code.
  2. Open the integrated terminal (View > Terminal).
  3. Run the following command to create a new .NET console application:

    dotnet new console -n MyTextControlApp
  4. Change to the project directory:

    cd MyTextControlApp
  5. Open the project in Visual Studio Code:

    code .

Adding NuGet.config

To use the TX Text Control NuGet packages, you need to add a NuGet.config file to your project. This file contains the configuration for NuGet package sources.

To add the NuGet.config file, follow these steps:

  1. In the root directory of your project, create a new file named NuGet.config.
  2. Add the following content to the NuGet.config file:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <add key="TextControlLocal" value="C:\Program Files (x86)\Text Control GmbH\NuGetPackages" />
      </packageSources>
    </configuration>

    Your NuGet Source

    Replace the value of the value attribute with the path to your local NuGet packages. This can be a local folder or a URL to your own NuGet package repository. The example above uses the default TX Text Control Offline NuGet package source.

  3. Save the NuGet.config file.

Adding the TX Text Control NuGet packages

To add the TX Text Control NuGet packages to your project, follow these steps:

  1. In the integrated terminal, run the following command to add the TX Text Control NuGet packages:

    dotnet add package TXTextControl.TextControl.Core.SDK

Creating a PDF file

To create a PDF file using the ServerTextControl, follow these steps:

  1. Open the Program.cs file in your project.
  2. Replace the existing code with the following code:

    using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
    {
        tx.Create();
        tx.Text = "This is a sample document.";
        tx.Save("sample.pdf", TXTextControl.StreamType.AdobePDF);
    }
  3. Save the Program.cs file.

Running the application

To run the application and create the PDF file, follow these steps:

  1. In the integrated terminal, run the following command:

    dotnet run
  2. After running the application, you should see a new PDF file named sample.pdf in the project directory.

Conclusion

In this tutorial, you learned how to create a new .NET console application using .NET 8 or later and how to use the ServerTextControl to create a PDF file.

Now you can use the TX Text Control SDK to create and manipulate documents in your .NET applications.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETASP.NET CoreLinux

Version 33.0 Preview: NuGet Packages Explained and Why we Minimize Dependencies

This article explains the new NuGet packages for TX Text Control .NET Server and ASP.NET Core. We also explain why we minimize dependencies in our packages.


ASP.NETASP.NET CoreCI/CD

Building a TX Text Control Project with GitHub Actions and the Text Control…

This tutorial provides a step-by-step guide to setting up a clean, reproducible environment using GitHub Actions. It starts with a brand-new project and ends with a fully automated build and test…


ASP.NETASP.NET CoreDocument Editor

ASP.NET Core Document Editor with Backend via the Text Control Private NuGet…

This article demonstrates how to create a Document Editor ASP.NET Core application using the Text Control Private NuGet Feed. We will build a basic web application that enables users to edit…


ASP.NETWPFASP.NET Core

Text Control Private NuGet Feed

The Text Control private NuGet feed delivers your licensed packages with zero friction. Your license is automatically embedded in every download. No manual license file management. No hunting for…


ASP.NETASP.NET CoreDocumentEditor

Document Editor with TX Spell .NET on Linux using ASP.NET Core

Learn how to integrate TX Spell .NET with the Document Editor on a Linux server using ASP.NET Core. This guide covers setup, configuration, and best practices for seamless spell checking…

Summarize this blog post with:

Share on this blog post on: