A
Abhishek R Prajapati
Guest
Hello guys,
I have one windows service which is printing multiple documents based on inputs. My function is performing below actions:
1. Getting list of data based on user inputs(using signalR). No of records can be any numbers from 1 to 5000.
2. Designing label for each record.
3. Print using System.Drawing.Printing.PrintDocument - Print method.
Now for small number of records, the whole process works fine. But with 2000+ records, system throws below exception:
System.Drawing.Printing.InvalidPrinterException: Settings to access printer 'PRINTER_NAME' are not valid.
at System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal(String printer)
at System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal()
at System.Drawing.Printing.PrinterSettings.CreateDeviceContext(PageSettings pageSettings)
at System.Drawing.Printing.PageSettings.get_HardMarginY()
This one comes when I try to access DefaultPageSettings:
var ps = printDocument.PrinterSettings.DefaultPageSettings;
var hardMargin = ps.HardMarginY;
Before fetching records, I tried to access the same settings and I got those settings without any error. So this error comes when I have high number of records.
I have gone through some suggestions on internet like change registery, windows impersonate(tried - no luck) but It is not the case here as It works for small number of records.
Any idea will be highly appreciated.
Thanks,
A.R.Prajapati
Continue reading...
I have one windows service which is printing multiple documents based on inputs. My function is performing below actions:
1. Getting list of data based on user inputs(using signalR). No of records can be any numbers from 1 to 5000.
2. Designing label for each record.
3. Print using System.Drawing.Printing.PrintDocument - Print method.
Now for small number of records, the whole process works fine. But with 2000+ records, system throws below exception:
System.Drawing.Printing.InvalidPrinterException: Settings to access printer 'PRINTER_NAME' are not valid.
at System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal(String printer)
at System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal()
at System.Drawing.Printing.PrinterSettings.CreateDeviceContext(PageSettings pageSettings)
at System.Drawing.Printing.PageSettings.get_HardMarginY()
This one comes when I try to access DefaultPageSettings:
var ps = printDocument.PrinterSettings.DefaultPageSettings;
var hardMargin = ps.HardMarginY;
Before fetching records, I tried to access the same settings and I got those settings without any error. So this error comes when I have high number of records.
I have gone through some suggestions on internet like change registery, windows impersonate(tried - no luck) but It is not the case here as It works for small number of records.
Any idea will be highly appreciated.
Thanks,
A.R.Prajapati
Continue reading...