Printing: Show message box when error in printing process occurs

This commit is contained in:
2024-01-25 19:40:56 +01:00
parent 0fff698a5d
commit 46498ce337

View File

@ -74,12 +74,16 @@ namespace Elwig.Helpers.Printing {
}
public static async Task Print(string path, int copies = 1) {
try {
var p = new Process() { StartInfo = new() { FileName = PdfToPrinter } };
p.StartInfo.ArgumentList.Add(path);
p.StartInfo.ArgumentList.Add("/s");
p.StartInfo.ArgumentList.Add($"copies={copies}");
p.Start();
await p.WaitForExitAsync();
} catch (Exception e) {
MessageBox.Show("Beim Drucken ist ein Fehler aufgetreten:\n\n" + e.Message, "Fehler beim Drucken");
}
}
}
}