# Printing

> Fix printing problems of TX Text Control .NET for Windows Forms: disabled printing, wrong page ranges, the status dialog, breaks that differ and slow start.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Troubleshooting > Printing
- **1271 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/printing/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/printing/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/printing/llms-full.txt

---

When printing from TX Text Control .NET for Windows Forms doesn't do what you expect, TX Text Control usually shows no error: the document prints the wrong pages, looks different on paper, or doesn't print at all. The problems below start from what you see. [Print a Document](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-processing/print/llms-full.txt) shows how printing works in the first place.

### Printing Is Disabled or Does Nothing

The **Print** command of your application is grayed out or doesn't print, while other documents print.

Whether a document can be printed depends on the document. [CanPrint](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/canprint-property/llms-full.txt) tells you, and its value depends on [DocumentPermissions.AllowPrinting](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documentpermissions/allowprinting-property/llms-full.txt) and the current [EditMode](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/editmode-property/llms-full.txt). `AllowPrinting` is `true` by default. A PDF document can also restrict printing: when the permissions of a loaded PDF don't allow printing, an application should disable its print command.

1. Check `CanPrint` before you call [Print](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/print-method/llms-full.txt), and enable or disable your print command with it.
2. If the document is protected, check the edit mode and the [DocumentPermissions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/documentpermissions-property/llms-full.txt) that the document sets.
3. For a PDF document, check [LoadSettings.DocumentAccessPermissions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsettings/documentaccesspermissions-property/llms-full.txt) after loading, as [Respect the Permissions of a PDF](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/security/pdf-passwords/#respect-the-permissions-of-a-pdf) shows. If you have the owner password, load the document with it in [MasterPassword](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsavesettingsbase/masterpassword-property/llms-full.txt): then all permissions are granted.

### The Whole Document Prints Instead of Some Pages

You set `FromPage` and `ToPage` of the `PrintDocument`, but every page of the document prints.

A page range takes effect only when the `PrintRange` of the printer settings is `PrintRange.SomePages`.

1. Set `PrinterSettings.PrintRange` of the `PrintDocument` to `PrintRange.SomePages`.
2. Set `FromPage` and `ToPage`. [Pages](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/pages-property/llms-full.txt) returns the number of pages, so that `ToPage` doesn't exceed it.
3. Pass the `PrintDocument` to `Print`.

[Print Without a Dialog](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-processing/print/#print-without-a-dialog) shows the code.

### A Status Dialog Appears While Printing

While the document prints, a dialog box of .NET shows the page being printed, for example:

```text
Page 5 of document
```

The default print controller of .NET shows this dialog. TX Text Control uses the print controller of the `PrintDocument` you pass.

1. Create a `StandardPrintController` and assign it to the `PrintController` of the `PrintDocument`.
2. Pass the `PrintDocument` to `Print`.

### Line and Page Breaks on Paper Differ From the Screen

The printed document breaks lines or pages in other places than the editor shows.

TX Text Control formats a document with the text dimensions of the printer that [FormattingPrinter](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/formattingprinter-property/llms-full.txt) names, as [The Layout Depends on the Printer](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/fonts/#the-layout-depends-on-the-printer) explains. When the document is printed on another printer, or formatted with the value `Display`, the dimensions on paper can differ.

1. Set `FormattingPrinter` to the printer you print on.
2. On machines where that printer isn't installed, expect the formatting of the standard printer, or name a printer that every machine has.

[Format the Document for the Printer](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-processing/print/#format-the-document-for-the-printer) shows the setting.

### The Editor Starts Slowly

Creating the first `TextControl` or `ServerTextControl` takes seconds, especially on machines with a network or wireless default printer.

When TX Text Control initializes, it asks the default printer for its dimensions, even when `FormattingPrinter` is `Display`. A printer that is in energy saving mode or answers slowly over the network delays the initialization.

1. In `Main` of *Program.cs*, set the static property `DefaultFormattingPrinter` to `Display` before the first control is created, as [Start Without Waiting for a Printer](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/performance/best-practices/#start-without-waiting-for-a-printer) shows.
2. Rebuild the application and compare the start time.

`DefaultFormattingPrinter` has no page in the reference; the blog article [Initialize Text Control Without a Printer (Completely)](https://www.textcontrol.com/blog/2022/02/28/initialize-text-control-without-a-printer-completely/) is its source.

### Documents Look Different When the Print Spooler Is Disabled

With the Windows Print Spooler service stopped or disabled, documents are laid out differently than on other machines.

Without the print spooler, TX Text Control can't reach a printer and uses the screen for formatting. Documents can then be rendered differently than usual, and a `FormattingPrinter` you set is no longer used. The blog article [Impact by "PrintNightmare" Vulnerability on DocumentEditor](https://www.textcontrol.com/blog/2021/07/14/impact-by-printnightmare-vulnerability-on-documenteditor/) describes this fallback.

1. Start the Print Spooler service again, and keep it running on machines that run your application.

### Related Pages

- [Print a Document](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-processing/print/llms-full.txt): print with and without a dialog.
- [Printing and Print Preview](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/printing/llms-full.txt): printing from the editor in detail.
- [Fonts and Document Layout](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/fonts/llms-full.txt): text that looks different on paper for other reasons.

---

## Nearby

- **Previous:** [High DPI and Scaling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/dpi-scaling/llms-full.txt)
- **Next:** [Document Conversion](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/troubleshooting/conversion/llms-full.txt)
