To add a Vadim restriction, you can set a default printer before printing using:
static void SetAsDefaultPrinter(string printerDevice) { foreach (var printer in PrinterSettings.InstalledPrinters) {
And slightly changing the PrintHtml method with
public void PrintHtml(string htmlPath, string printerDevice) { if (!string.IsNullOrEmpty(printerDevice)) SetAsDefaultPrinter(printerDevice); Task.Factory.StartNew(() => PrintOnStaThread(htmlPath), CancellationToken.None, TaskCreationOptions.None, _sta).Wait(); }
Now I do not know how this will be true in heavy printing, given that there may be a problem with concurrency when changing the default printer many times. But for now, this is the best I have come up with to fix this limitation.
Nick-acnb
source share