I'm trying to print a external pdf file with printdialog options but the file is printed with predeterminated printer config
Dim result As DialogResult = PrintDialog1.ShowDialog()
If (result = DialogResult.OK) Then
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.Verb = "print"
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.Arguments = PrintDialog1.PrinterSettings.PrinterName.ToString()
psi.FileName = "file.pdf"
Process.Start(psi)
End If
You would need to use the "PrintTo" verb rather than the "Print" verb. You would also need to wrap the printer name in quotes if it might have spaces in it. I would suggest making your code a bit more succinct:
Process.Start(New ProcessStartInfo("file.pdf",
$"""{PrintDialog1.PrinterSettings.PrinterName}""") With {.Verb = "printto",
.UseShellExecute = True,
.WindowStyle = ProcessWindowStyle.Hidden})