# How to Create PDF Documents with TX Text Control using C# .NET on Linux

> This article shows how to create professional PDF and PDF/A documents using ASP.NET Core C# on Linux. TX Text Control enables the creation of pixel-perfect PDF documents on any Linux environment that supports .NET, including Debian, Ubuntu, and Azure App Services.

- **Author:** Bjoern Meyer
- **Published:** 2025-03-18
- **Modified:** 2025-11-29
- **Updated:** 2025-11-19
- **Description:** This article shows how to create professional PDF and PDF/A documents using ASP.NET Core C# on Linux. TX Text Control enables the creation of pixel-perfect PDF documents on any Linux environment that supports .NET, including Debian, Ubuntu, and Azure App Services.
- **6 min read** (1090 words)
- **Tags:**
  - ASP.NET
  - ASP.NET Core
  - Linux
  - PDF
- **Web URL:** https://www.textcontrol.com/blog/2025/03/18/how-to-create-pdf-documents-with-tx-text-control-using-c-sharp-net-on-linux/
- **LLMs URL:** https://www.textcontrol.com/blog/2025/03/18/how-to-create-pdf-documents-with-tx-text-control-using-c-sharp-net-on-linux/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2025/03/18/how-to-create-pdf-documents-with-tx-text-control-using-c-sharp-net-on-linux/llms-full.txt

---

Programmatic PDF generation is a common requirement in modern applications, whether for invoices, reports, or dynamically generated documents. While .NET developers have several options for PDF creation, achieving high-quality, feature-rich documents on Linux can be challenging.

In this tutorial, we'll explore how to use TX Text Control to create, modify, and export PDF documents in a C#.NET application running on Linux. We'll walk through the setup, cover the key APIs, and demonstrate how to create PDFs with text formatting, images, and tables - all while leveraging the power of TX Text Control's document processing capabilities.

You will have a fully functional .NET-based PDF creation solution running seamlessly on Linux by the end of this guide.

> ### Prerequisites
> 
> You need to download and install the trial version of TX Text Control .NET Server:
> 
> - [Download Trial Version](https://www.textcontrol.com/product/tx-text-control-dotnet-server/download/)  
>     Setup download and installation required.

### Creating the Application

Make sure that you downloaded the latest version of Visual Studio 2022 that comes with the [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).

1. In Visual Studio 2022, create a new project by choosing *Create a new project*.
2. Select *Console App* as the project template and confirm with *Next*.
3. Enter a project name and choose a location to save the project. Confirm with *Next*.
4. Choose *.NET 8.0 (Long Term Support)* as the *Framework*.
5. Enable the *Enable container support* checkbox and choose *Linux* as the *Container OS*.
6. Choose *Dockerfile* for the *Container build type* option and confirm with *Create*.
    
    ![Creating the .NET 8 project](https://s1-www.textcontrol.com/assets/dist/blog/2025/03/18/a/assets/visualstudio1.webp "Creating the .NET 8 project")

#### Adding the NuGet Packages

7. In the *Solution Explorer*, select your created project and choose *Manage NuGet Packages...* from the *Project* main menu. Select **Text Control Offline Packages** as the *Package source*.
    
    Install the following package:
    
    
    - **TXTextControl.TextControl.Core.SDK**
    
    ![ASP.NET Core Web Application](https://s1-www.textcontrol.com/assets/dist/blog/2025/03/18/a/assets/visualstudio2.webp "ASP.NET Core Web Application")

#### Using ServerTextControl and MailMerge

8. Find the *Program.cs* file in the *Solution Explorer* and replace the code with the following code snippet:
    
    ```
    using TXTextControl;
    
    using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
    {
        tx.Create();
    
        // Add a paragraph to the document
        TXTextControl.Selection selection = new TXTextControl.Selection(0, 0);
        selection.Text = "Hello, Linux!";
    
        // Set the paragraph format
        selection.ParagraphFormat = new ParagraphFormat()
        {
            Alignment = HorizontalAlignment.Center,
            BackColor = System.Drawing.Color.LightGray,
            Frame = Frame.BottomLine,
            FrameLineColor = System.Drawing.Color.Red,
            FrameStyle = FrameStyle.Double,
            FrameLineWidth = 10,
        };
    
        // Set the font format
        selection.FontSize = 240; // 240 twips = 12 pt
        selection.FontName = "Arial";
        selection.Bold = true;
    
        // Apply the changes to the document
        tx.Selection = selection;
    
        // Save the document
        tx.Save("results.pdf", TXTextControl.StreamType.AdobePDF);
    }
    ```
9. Now run the project that runs the application in a Docker container that uses the default Debian container with the .NET 8.0 runtime preinstalled.

It creates a new document, inserts a paragraph with a defined format-including borders, alignment, and character style-and then saves the document as a PDF file.

![Created document with TX Text Control](https://s1-www.textcontrol.com/assets/dist/blog/2025/03/18/a/assets/pdf1.webp "Created document with TX Text Control")

#### Adding Tables

Inserting tables into a document is as easy as adding text. The following code snippet demonstrates how to create a table and apply formatting, including cell borders and background colors.

```
using TXTextControl;

using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
    tx.Create();

    tx.Tables.Add(5,5,10);

    // Get the table from ID
    Table table = tx.Tables.GetItem(10);

    // Set the table border style
    TableCellFormat cellFormat = new TableCellFormat() {
        BottomBorderWidth = 1,
        BottomBorderColor = System.Drawing.Color.Red,
        TopBorderWidth = 1,
        TopBorderColor = System.Drawing.Color.Red,
        LeftBorderWidth = 1,
        LeftBorderColor = System.Drawing.Color.Red,
        RightBorderWidth = 1,
        RightBorderColor = System.Drawing.Color.Red,

        BottomTextDistance = 80,
        TopTextDistance = 80,
        LeftTextDistance = 120,
        RightTextDistance = 120
    };

    // Loop through all cells and set the cell format
    foreach (TableCell cell in table.Cells)
    {
        cell.CellFormat = cellFormat;
        cell.Text = $"Cell: {cell.Row}/{cell.Column}";
    }

    // Highlight the first column and row
    TableCellFormat highlightCellFormat = new TableCellFormat()
    {
        BackColor = System.Drawing.Color.LightGray
    };

    table.Columns.GetItem(1).CellFormat = highlightCellFormat;
    table.Rows.GetItem(1).CellFormat = highlightCellFormat;

    // Save the document
    tx.Save("results.pdf", TXTextControl.StreamType.AdobePDF);
}
```

When viewed in Adobe Acrobat Reader, the PDF document looks like this:

![Created document with a table](https://s1-www.textcontrol.com/assets/dist/blog/2025/03/18/a/assets/pdf2.webp "Created document with a table")

#### Adding Headers and Footers

You can add headers and footers to a document using the HeadersAndFooters collection. The following code snippet inserts a header into the current section with an image in the right corner and page number fields.

```
using TXTextControl;
	
	using (ServerTextControl tx = new ServerTextControl())
	{
	    tx.Create();
	
	    // Add a header
	    tx.Sections.GetItem().HeadersAndFooters.Add(HeaderFooterType.Header);
	
	    // Get the header/footer object
	    HeaderFooter headerFooter = tx.Sections.GetItem().HeadersAndFooters.GetItem(HeaderFooterType.Header);
	
	    // Add an image to the header
	    Image image = new Image("tx_logo.svg", 0);
	    headerFooter.Images.Add(image, HorizontalAlignment.Right, 1, ImageInsertionMode.AboveTheText);
	
	    // Add a text to the header
	    headerFooter.Selection.Text = "Header Text\r\n\r\n";
	
	    // Add a page number field to the header
	    headerFooter.Selection.Text = "Page ";
	    headerFooter.PageNumberFields.Add(new PageNumberField());
	    headerFooter.Selection.Text = " of ";
	    headerFooter.PageNumberFields.Add(new PageNumberField() { ShowNumberOfPages = true });
	
	    // Add a new page
	    tx.Selection.Text = "\f";
	
	    // Save the document
	    tx.Save("results.pdf", StreamType.AdobePDF);
	}
```

Here is the result when viewed in Adobe Acrobat Reader:

![Created document with a header](https://s1-www.textcontrol.com/assets/dist/blog/2025/03/18/a/assets/pdf3.webp "Created document with a header")

#### More PDF Options

TX Text Control provides advanced PDF settings, including encryption, compression, and PDF/A compliance. Developers can configure digital signatures and PDF/A compliance using the SaveSettings class. When opened in Acrobat Reader, the document displays a compliance notification and allows signature verification.

![Created document with a header](https://s1-www.textcontrol.com/assets/dist/blog/2025/03/18/a/assets/pdf4.webp "Created document with a header")

In addition, TX Text Control supports PDF/A-3 compliant documents, enabling embedded files. Developers can set UserPassword (to open the document) and MasterPassword (to manage access rights) to control permissions such as printing and form field creation. Learn more about evaluating cross-platform support and other key criteria in this [guide to choosing a C# PDF generation library.](https://www.textcontrol.com/blog/2025/11/12/how-to-choose-the-right-csharp-pdf-generation-library-developer-checklist/llms-full.txt)

#### Conclusion

TX Text Control provides a powerful document processing API for .NET developers to create, modify, and export PDF documents in Linux environments. By following this guide, you will have learned how to create a .NET application that generates high-quality PDFs with text formatting, images, tables, headers, footers, and advanced PDF settings.

TX Text Control enables the creation of pixel-perfect PDF documents on any Linux environment that supports .NET, including Debian, Ubuntu, and Azure App Services.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Convert MS Word DOCX to PDF including Text Reflow using .NET C# on Linux](https://www.textcontrol.com/blog/2025/06/10/convert-ms-word-docx-to-pdf-including-text-reflow-using-dotnet-csharp-on-linux/llms.txt)
- [TX Text Control Linux Preview: Font Handling](https://www.textcontrol.com/blog/2024/12/28/tx-text-control-linux-preview-font-handling/llms.txt)
- [Using QR Codes in PDF Documents in C# .NET](https://www.textcontrol.com/blog/2026/04/21/using-qr-codes-in-pdf-documents-in-csharp-dotnet/llms.txt)
- [Why Structured E-Invoices Still Need Tamper Protection using C# and .NET](https://www.textcontrol.com/blog/2026/03/24/why-structured-e-invoices-still-need-tamper-protection-using-csharp-and-dotnet/llms.txt)
- [Create Fillable PDFs from HTML Forms in C# ASP.NET Core Using a WYSIWYG Template](https://www.textcontrol.com/blog/2026/03/17/create-fillable-pdfs-from-html-forms-in-csharp-aspnet-core-using-a-wysiwyg-template/llms.txt)
- [Why HTML to PDF Conversion is Often the Wrong Choice for Business Documents in C# .NET](https://www.textcontrol.com/blog/2026/03/13/why-html-to-pdf-conversion-is-often-the-wrong-choice-for-business-documents-in-csharp-dot-net/llms.txt)
- [Document Editor with TX Spell .NET on Linux using ASP.NET Core](https://www.textcontrol.com/blog/2026/01/28/document-editor-tx-spell-net-linux-aspnet-core/llms.txt)
- [A Complete Guide to Converting Markdown to PDF in .NET C#](https://www.textcontrol.com/blog/2026/01/07/a-complete-guide-to-converting-markdown-to-pdf-in-dotnet-csharp/llms.txt)
- [Why PDF Creation Belongs at the End of the Business Process](https://www.textcontrol.com/blog/2026/01/02/why-pdf-creation-belongs-at-the-end-of-the-business-process/llms.txt)
- [Designing the Perfect PDF Form with TX Text Control in .NET C#](https://www.textcontrol.com/blog/2025/12/16/designing-the-perfect-pdf-form-with-tx-text-control-in-dotnet-csharp/llms.txt)
- [Why Defining MIME Types for PDF/A Attachments Is Essential](https://www.textcontrol.com/blog/2025/12/10/why-defining-mime-types-for-pdfa-attachments-is-essential/llms.txt)
- [Validate Digital Signatures and the Integrity of PDF Documents in C# .NET](https://www.textcontrol.com/blog/2025/11/14/validate-digital-signatures-and-the-integrity-of-pdf-documents-in-csharp-dotnet/llms.txt)
- [Validate PDF/UA Documents and Verify Electronic Signatures in C# .NET](https://www.textcontrol.com/blog/2025/11/13/validate-pdf-ua-documents-and-verify-electronic-signatures-in-csharp-dotnet/llms.txt)
- [How To Choose the Right C# PDF Generation Library: Developer Checklist](https://www.textcontrol.com/blog/2025/11/12/how-to-choose-the-right-csharp-pdf-generation-library-developer-checklist/llms.txt)
- [Why Digitally Signing your PDFs is the Only Reliable Way to Prevent Tampering](https://www.textcontrol.com/blog/2025/10/30/why-digitally-signing-your-pdfs-is-the-only-reliable-way-to-prevent-tampering/llms.txt)
- [Automating PDF/UA Accessibility with AI: Describing DOCX Documents Using TX Text Control and LLMs](https://www.textcontrol.com/blog/2025/10/16/automating-pdf-ua-accessibility-with-ai-describing-docx-documents-using-tx-text-control-and-llms/llms.txt)
- [Converting Office Open XML (DOCX) to PDF in Java](https://www.textcontrol.com/blog/2025/10/14/converting-office-open-xml-docx-to-pdf-in-java/llms.txt)
- [Extending DS Server with Custom Digital Signature APIs](https://www.textcontrol.com/blog/2025/10/09/extending-ds-server-with-custom-digital-signature-apis/llms.txt)
- [Why PDF/UA and PDF/A-3a Matter: Accessibility, Archiving, and Legal Compliance](https://www.textcontrol.com/blog/2025/10/07/why-pdf-ua-and-pdf-a-3a-matter-accessibility-archiving-and-legal-compliance/llms.txt)
- [Convert Markdown to PDF in a Console Application on Linux and Windows](https://www.textcontrol.com/blog/2025/09/23/convert-markdown-to-pdf-in-a-console-application-on-linux-and-windows/llms.txt)
- [Mining PDFs with Regex in C#: Practical Patterns, Tips, and Ideas](https://www.textcontrol.com/blog/2025/08/12/mining-pdfs-with-regex-in-csharp-practical-patterns-tips-and-ideas/llms.txt)
- [Streamline Data Collection with Embedded Forms in C# .NET](https://www.textcontrol.com/blog/2025/08/02/streamline-data-collection-with-embedded-forms-in-csharp-dotnet/llms.txt)
- [Adding QR Codes to PDF Documents in C# .NET](https://www.textcontrol.com/blog/2025/07/15/adding-qr-codes-to-pdf-documents-in-csharp-dotnet/llms.txt)
- [Adding SVG Graphics to PDF Documents in C# .NET](https://www.textcontrol.com/blog/2025/07/08/adding-svg-graphics-to-pdf-documents-in-csharp-dotnet/llms.txt)
- [Enhancing PDF Searchability in Large Repositories by Adding and Reading Keywords Using C# .NET](https://www.textcontrol.com/blog/2025/06/24/enhancing-pdf-searchability-in-large-repositories-by-adding-and-reading-keywords-using-csharp-dotnet/llms.txt)
