I've search through the forum and found a few articles that talk about printing to PDF, but there were pretty old. I have the following code, but it doesn't work.
PdfViewer viewer = new PdfViewer();
viewer.BindPdf(pdfDoc);
viewer.PrintPageDialog = false;
viewer.AutoResize = true;
viewer.AutoRotate = true;
PrinterSettings ps = new PrinterSettings();
PageSettings pgs = new PageSettings();
PrintDocument prtdoc = new PrintDocument();
ps.PrinterName = prtdoc.PrinterSettings.PrinterName;
viewer.PrintDocumentWithSettings(pgs, ps);
//viewer.PrintDocumentWithSetup();
viewer.Close();
I got the following error:
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.