views:

394

answers:

2

I have simple text file, and i have to print it using WPF. How can i print this file with specified printer setting(like margin, print on both side).

+2  A: 

Microsoft has introduced a new printing API as part of WPF. You can read more about Printing and Print System Management on MSDN. You will have to format the text into an XPS document which you can then print. There is a sample on how to programmatically print XPS files.

Martin Liversage
+1  A: 

Convert the file to a FlowDocument, then print that. The trick is in loading the text into the FlowDocument, See:

http://someblokeontheinternet.blogspot.com/2009/11/printing-contents-of-text-box-or-just.html

Jason Harrison