I’m the developer of an application which supports automatic printing of files of various formats with different settings in some very special context. Those different settings contain the paper bin to use and the duplex mode, if any at all. Because we need to support various formats, the currently implemented approach is to set default printer settings for the current user in Windows to the settings we need and afterwards use whatever native application is able to print some format. Sometimes this simply includes executing ShellExecute with the “print” verb and let Windows handle everything else, sometimes we directly execute apps using a specially configured command line etc. This approach worked quite well for some years now.
One of my customers recently changed its printer from some small business HP device to a Konica Minolta bizhub C658 and starting with that we recognized printing errors in the special case a PDF is printed using the PDF Viewer SumatraPDF on the command line. It’s really only the printer that changed, nothing else related our app, Sumatra, the OS or whatever and I can reproduce that error with the same printer on my own laptop using different verison of Windows, as long as my settings as well use SumatraPDF. If SumatraPDF is replaced with some other printing app, things start working again as expected, no exceptions. For various reasons we would like to stay with SumatraPDF, though.
So, I’m pretty sure that the problem is the combination of SumatraPDF and the concrete printer. What happens is, that after setting some combinations of default printer settings to print individual PDFs, it seems that the printer is simply ignoring my settings and printing pages according to some own, maybe internal defaults. Some example: 4 PDFs which I want to print simplex, duplex, simplex, duplex. The default printer settings before my app starts working are set to simplex. What happens is that all but the last PDF print correctly as expected, but the last one is printed simplex instead of duplex. If the printer settings were set to duplex by default before my app was started, the third PDF would have been printed as duplex already instead of simplex and the 4th PDF would be printed as duplex as well.
My app is strictly following the API docs of Microsoft regarding changing printer settings using
SetPrinter and this worked with SumatraPDF and the HP printers for years and with some replacement for SumatraPDF and keeping the Konica printer as well. Additionally, during debugging my app I can see that in all cases my settings for the printer are successfully applied and visible in the printer dialogue in Windows right before Sumatra starts working. Obviously, I don’t get any error from the Windows API that setting my new settings failed as well. Though, after some successful prints my settings seem to be ignored at some point during actual printing.
It might be important to note as well that SumatraPDF is not started with any custom print settings or such, it just prints to the default printer with its current settings. Reviewing the printing code of Sumatra doesn’t reveal any obvious error and as said before, using the HP printers it worked for years.
In the end, I would like to ask if someone ever heard of a similar problem or has any advice on how to debug this further. Is there any tracing log in the printer driver or on the device? Where might the wrong default settings come from, if those are not the one set by my app for the current user? It seems like it’s always those settings set before my app started working, but I’m using the user related printing API of Windows as well.
The MSDN contains something which reads like is the problem I’m facing:
When you call CreateDC to create the HDC for a printer device, the printer driver validates the DEVMODE. If the printer driver determines that the DEVMODE is invalid (that is, printer driver can’t convert or consume the DEVMODE), the printer driver provides a default DEVMODE to create the HDC for the printer device.
But as my problem doesn’t occur always, only after some successful prints and only with SumatraPDF, which is not changing
DEVMODE according to what I see in the code, it should be something different damaging
DEVMODE then. Additionally, it would be nice to know where that “default
DEVMODE” structure comes from.
If there’s anyone out there with some useful idea about how to debug this, what the problem might be etc. I would be very thankful! Thew only solution I currently have is to not use Sumatra with those printers, but having no idea why is bad. 🙂
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!