1

I am very new to c#/WPF and I need help with what should be a very simple app. In the app I am designing a user simply browses for a .txt or .jpg file which is then loaded. I would like the user to then be able to print what's displayed. The code I have found to work appears to only print part of the contents on one page. In addition, when the .txt files are printed there are no margins and the text seems to go right off the page. Here is the code I am using as it seems to be very basic.

System.Windows.Controls.PrintDialog pd = new System.Windows.Controls.PrintDialog();
if (pd.ShowDialog() != true) return;
pd.PrintVisual(textbox2, "textbox2.");

I guess my question would be, how do I set margin spacing and allow for multiple page document printing? Any help would be greatly appreciated. Thank you.

user2029074
  • 59
  • 1
  • 10

1 Answers1

0

To print text files you will probably want to use a FlowDocument, this allows you to set margins, pagination etc, e.g. Printing a WPF FlowDocument

To print a JPEG, you can use PrintVisual, e.g. Load image from file and print it using WPF... how?

Community
  • 1
  • 1
RobJohnson
  • 875
  • 11
  • 21