TX Text Control .NET Server

Printing

Topic

Users print a document from the toolbar of the Document Viewer, and your code can start printing from buttons on your own page. For browsers that don't support printing from the viewer, your page can offer the document as a PDF file instead.

The examples change the view of the ASP.NET Core tutorial.

How Printing Works

The toolbar of the viewer has two buttons for getting a document out of the viewer:

  • Print prints the document with the print function of the browser. The browser shows its print dialog.
  • Download downloads the document as a PDF file, which users open and print with any application.

Not all browsers support printing from the viewer. For users of such browsers, offer the download.

The Formatting Printer

DocumentViewerSettings.FormattingPrinter sets the name of a printer whose text dimensions format the document, so that the displayed and the printed document have the same dimensions when the document is printed with this printer:

  • "Standard" uses the installed standard printer of the system.
  • "Display" uses the font dimensions of the display.
  • If the named printer isn't installed, the standard printer is used.
@Html.TXTextControl().DocumentViewer(settings => {
    settings.DocumentPath = "App_Data/template.docx";
    settings.Dock = DocumentViewerSettings.DockStyle.Fill;
    settings.FormattingPrinter = "Display";
}).Render()

The reference doesn't state whether this setting has an effect with the Core engine. For the Document Editor, printer-specific formatting isn't supported by its cross-platform backend; see Viewing and Printing.

Next Steps