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 CoreDOCX

Convert MS Word DOCX to PDF including Text Reflow using .NET C# on Linux

This article explains how to use TX Text Control .NET Server to convert a Microsoft Word DOCX document to a PDF file on a Linux system using .NET C#. This conversion process includes text reflow,…


ASP.NETASP.NET CoreDocker

Announcing the Official DS Server Docker Image on Docker Hub

The official DS Server Docker image is now available on Docker Hub. This makes it easier to deploy the DS server in a containerized environment and manage and scale your applications. Based on the…


ASP.NETASP.NET CoreDS Server

Introducing DS Server 4.0: Linux-Ready and Container-Friendly

We are excited to announce the release of DS Server 4.0, our latest major update that makes your document processing workflows more flexible and powerful. This release marks two significant…


ASP.NETASP.NET CoreDocker

Using a Private NuGet Feed to Build and Restore .NET Apps for Docker Deployment

Learn how to set up a private NuGet feed for your .NET applications and use them in Docker containers. This guide covers the steps to create a private NuGet feed with GitHub, configure your .NET…