Printing
When printing from TX Text Control .NET for WPF 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 WPF TextControl prints with the print system of WPF, while ServerTextControl and MailMerge print with a PrintDocument of .NET, and the problems of the two ways differ. Printing and Print Preview describes printing when everything works.
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 tells you, and its value depends on DocumentPermissions.AllowPrinting and the current EditMode. 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.
- Check
CanPrintbefore you call Print, and enable or disable your print command with it. - If the document is protected, check the edit mode and the DocumentPermissions that the document sets.
- For a PDF document, check LoadSettings.DocumentAccessPermissions after loading. If you have the owner password, load the document with it in MasterPassword: then all permissions are granted.
The Settings of the Print Dialog Are Ignored
You show the PrintDialog of WPF, and the user chooses a page range, the number of copies or collation, but the document prints with other settings.
Print doesn't read the settings of a PrintDialog that your code shows. It has overloads that take the printer, the page range, the number of copies and the collation, and these values must be passed from the dialog. The overload with a document name and a Boolean value shows the standard print dialog itself.
Pass the name of the printer queue, the page range, and the copy count and collation of the print ticket from the dialog to Print, as Connect the WPF Print Dialog shows. In a .NET Framework project, PrintQueue and PrintTicket need references to System.Printing.dll and ReachFramework.dll.
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 names, and printing on another printer, or formatting with Display, can move the breaks. Set FormattingPrinter to the printer you print on, or name a printer that every machine has, as The Layout Depends on the Printer explains.
A PrintDocument Prints All Pages Instead of Some
ServerTextControl.Print or MailMerge.Print prints every page, although you set FromPage and ToPage of the PrintDocument.
These methods print with a PrintDocument of .NET, and a page range takes effect only when the PrintRange of its printer settings is PrintRange.SomePages.
- Set
PrinterSettings.PrintRangeof thePrintDocumenttoPrintRange.SomePages. - Set
FromPageandToPage, and pass thePrintDocumenttoPrint, as Print a File in the Background shows.
A Status Dialog Appears While Printing a PrintDocument
While a ServerTextControl or MailMerge prints, a dialog box of .NET shows the page being printed, for example:
Page 5 of document
The default print controller of .NET shows this dialog, and TX Text Control uses the print controller of the PrintDocument you pass.
- Assign a new
StandardPrintControllerto thePrintControllerof thePrintDocument. - Pass the
PrintDocumenttoPrint.
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, and a printer in energy saving mode or on a slow network delays the start. Set the static property DefaultFormattingPrinter of TXTextControl.WPF.TextControl and ServerTextControl when the application starts, as Start Without Waiting for a Printer shows, and compare the start time.