WPF: Is there a way to use PrintDialog only to select the target printer without having to provide a DocumentPaginator class?

6.5k views Asked by At

I want to print a very simple layout with PrintDocument that fits on one page, so it doesn't require a DocumentPaginator. However I want to use PrinterDialog to select the printer. I saw examples with PrinterSettings being a property of PrinterDialog and it was simply assigned to the PrintDocument. But this doesn't seem to be possible anymore. I also looked for other solutions like custom paginator classes to use but came up empty. I might not have this deep insight into WPF, but why must it always be dongled that way...

1

There are 1 answers

1
Sam R. On BEST ANSWER

Try this:

  • Import System.Printing
  • Create a PrintDialog

And then:

PrintDialog printDialog = new PrintDialog();
printDialog.PrintQueue = new PrintQueue(new PrintServer(), "PrinterName");
printDialog.PrintDocument(document, "PrintDocument");