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 Formatting
╰ TXTextControl Namespace
╰ TextControl Class
╰ FormattingPrinter Property
Gets or sets the name of a printer the text dimensions and capabilities of which are used to format the document. 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 TXText
╰ TXTextControl Namespace
╰ TextControl Class
The TextControl class implements a Windows Forms control with high-level text editing features. and TXText
╰ TXTextControl Namespace
╰ ServerTextControl Class
The ServerTextControl class implements a component that provide high-level text processing features for server-based applications. 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