I have a WPF application and I use an external library to generate documents. This library returns the document as System.Drawing.Printing.PrintDocument. How to print this document in WPF? I can directly use the Print () method, but I need to allow the user to select the printer and settings. If I use the WPF PrintDocument dialog, I cannot set my document for it, as in the WinForms.Document dialog box. Is there a way to convert an old PrintDocument into some friendly WPF form?
WinForms method:
// get document for printing
PrintDocument document = exporter.GetPrintDocument();
System.Windows.Forms.PrintDialog dialog = new System.Windows.Forms.PrintDialog();
dialog.Document = document;
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
document.Print();
}
WPF method:
System.Windows.Controls.PrintDialog dialog = new System.Windows.Controls.PrintDialog();
if (dialog.ShowDialog() == true)
{
// how to print old PrintDocument???
dialog.PrintDocument(...);
}
I also tried to open the WinForms dialog in WPF, but that is not possible. The dialog is simply not shown.
Thanks for any help.