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 Server ╰ TX Text Control .NET Server for ASP.NET
╰ TXTextControl Namespace
╰ ServerTextControl Class
The ServerTextControl class implements a component that provide high-level text processing features for server-based applications. 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.
Create a new .NET console application
To create a new .NET console application, follow these steps:
- Open Visual Studio Code.
- Open the integrated terminal (View > Terminal).
-
Run the following command to create a new .NET console application:
dotnet new console -n MyTextControlApp -
Change to the project directory:
cd MyTextControlApp -
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:
- In the root directory of your project, create a new file named NuGet.config.
-
Add the following content to the
NuGet.config
file:This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters<?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.
- 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:
-
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 Server ╰ TX Text Control .NET Server for ASP.NET
╰ TXTextControl Namespace
╰ ServerTextControl Class
The ServerTextControl class implements a component that provide high-level text processing features for server-based applications. , follow these steps:
- Open the Program.cs file in your project.
-
Replace the existing code with the following code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersusing (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { tx.Create(); tx.Text = "This is a sample document."; tx.Save("sample.pdf", TXTextControl.StreamType.AdobePDF); } - Save the Program.cs file.
Running the application
To run the application and create the PDF file, follow these steps:
-
In the integrated terminal, run the following command:
dotnet run - 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 Server ╰ TX Text Control .NET Server for ASP.NET
╰ TXTextControl Namespace
╰ ServerTextControl Class
The ServerTextControl class implements a component that provide high-level text processing features for server-based applications. to create a PDF file.
Now you can use the TX Text Control SDK to create and manipulate documents in your .NET applications.