Products Technologies Demo Docs Blog Support Company

Initialize Text Control Without a Printer (Completely)

TX Text Control uses a printer or a screen device to render the text which results in a 100% accurate display of documents. This article shows how to create an instance without any calls to other printers that are not defined.

Initialize Text Control Without a Printer (Completely)

A unique feature of TX Text Control is the true WYSIWYG (what-you-see-is-what-you-get) rendering. TX Text Control uses a printer or a screen device to render text which results in a 100% accurate display of documents. The used device can be adjusted using the FormattingPrinter property.

The defined device is used to get font information of how a specific printer would print the text:

  • Exact character sizes
  • Font kerning
  • Spacing

Using this approach, the text on the screen is identical to what appears in a resulting PDF document or when it is printed (on that printer).

Pro Tip: Initialization Time

Please note that the printer response time can influence the initialization time of the Text Control instance. Consider a wireless printer that is in energy saving mode or other network related delays.

FormattingPrinter "Display"

If an application doesn't need a specific printer to be used, the FormattingPrinter property can be set to "Display" - a screen device that looks identical on all machines. But even if you define this rendering using the FormattingPrinter property, on initializing a new Text Control, the default printer is called to get most necessary information.

Static, Global Default Setting

Since version 30.0, the default formatting printer can be defined before a new instance of TXTextControl.TextControl class and TXTextControl.ServerTextControl class is created. When this default printer driver is defined, TX Text Control is not accessing any other (default) printer or printer spooler. This must be set using the new static property DefaultFormattingPrinter:

TXTextControl.TextControl.DefaultFormattingPrinter = "Display";

In a Windows Forms application, this property can be set in the Main entry point of the Program.cs:

static class Program {
  /// <summary>
  /// The main entry point for the application.
  /// </summary>
  [STAThread]
  static void Main() {
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);

    TXTextControl.TextControl.DefaultFormattingPrinter = "Display";
    Application.Run(new Form1());
  }
}

Every new instance of Text Control uses this default printer driver then:

TXTextControl.TextControl tx = new TXTextControl.TextControl();
Form1.ActiveForm.Controls.Add(tx);

Console.WriteLine(tx.FormattingPrinter);

This is the result in the output console:

Display

The same logic is followed for all ServerTextControl instances created in Windows Forms, WPF and ASP.NET (Core) applications. In ASP.NET, this static, global setting can be set in the Main entry point as well:

public class Program {
  public static void Main(string[] args) {
  
    TXTextControl.ServerTextControl.DefaultFormattingPrinter = "Display";
    
    CreateHostBuilder(args).Build().Run();
  }

  public static IHostBuilder CreateHostBuilder(string[] args) =>
     Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder => {
          webBuilder.UseStartup<Startup>();
        });
}

A new instance of ServerTextControl would use "Display" then:

using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
  tx.Create();
  Console.WriteLine(tx.FormattingPrinter);
}
Display

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.NETWindows FormsWPF

TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 3 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…


ASP.NETWindows FormsWPF

TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 2 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…


ASP.NETWindows FormsWPF

Document Lifecycle Optimization: Leveraging TX Text Control's Internal Format

Maintaining the integrity and functionality of documents throughout their lifecycle is paramount. TX Text Control provides a robust ecosystem that focuses on preserving documents in their internal…


ActiveXASP.NETWindows Forms

Expert Implementation Services for Legacy System Modernization

We are happy to officially announce our partnership with Quality Bytes, a specialized integration company with extensive experience in modernizing legacy systems with TX Text Control technologies.


ActiveXASP.NETWindows Forms

Service Pack Releases: What's New in TX Text Control 33.0 SP1 and 32.0 SP5

TX Text Control 33.0 Service Pack 1 and TX Text Control 32.0 Service Pack 5 have been released, providing important updates and bug fixes across platforms. These service packs improve the…