How to Print Textbox Text in Windows 8 Application

How to Print Textbox Text in Windows 8 Application


Microsoft's documentation and sample for printing is too much complex. The sample app for printing shows only how to print RichTextBlock. There is no tutorial to print the text box content in Windows Store app. Moreover to print single line of string, one has to write too much code rather than maximum 10 lines in WinForm. So this library provides a helper class which has only one static method. It prints the text box content with its formatting. It is mainly based on MSDN print sample.

I got an idea to write a library from the following Stack Overflow questions.

How to print the contents of a TextBox

How do you print contents of a RichTextBox?

How do I print a TextFile OR contents of a TextBox in Metro apps?


You have to call just one static method, it will do print job on your behalf.

await Printer.ShowPrintUIAsync(PrintPreview, MyTextBox, Guid.NewGuid().ToString());
  • PrintPreview is a canvas, which is mandatory to show print preview in device charm. You have to declare it in your XAML.
  • MyTextBox is a text box object, whose text content is going to be printed.
  • Guid.NewGuid().ToString() is a file name for printing the document. (It will be applied if you are creating PDF or XPS file via printing.)

You can find NuGet package here and GitHub repo here

I would be glad to receive suggestions from you (or bug reports), so I can improve this class. Ping me on my twitter handle _F4RH4N_.
Leave a Comment
  • Please add 3 and 3 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
  • You may want to provide more description and code.

  • I have added the project on GitHub.

Page 1 of 1 (2 items)