I solved with some parameters that were missing in several tutorials I found and other answers here in Stacko, I do not know why exactly in the guys worked and in my no, maybe it is something relative with versions.
It turned out that I didn’t check if it was really necessary to convert the Printdialog Object to Printdocument, but that’s how I did it:
this.printDocumentFunciona = this.printDialog1.Document;
The implementation itself:
this.printDocumentFunciona.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";
this.printDocumentFunciona.DefaultPageSettings.PrinterSettings.PrintToFile = true;
this.printDocumentFunciona.DefaultPageSettings.PrinterSettings.PrintFileName = "NomeArquivo.xps";
this.printDocumentFunciona.PrintController = new StandardPrintController();
this.printDocumentFunciona.Print();
Importantly, if you select the Foxit Printer, it doesn’t work at all, the dialog always appears to choose the name, but using the Windows XPS printer or the Office/Windows PDF printer, it works without opening anything.
You can [Edit] the question and add the code?
– Jéf Bueno