Print .Net Bitmap with Win32 API
-
Does anybody know how I could print a .Net Bitmap with Win32 Api calls? Thanks alot
-
Does anybody know how I could print a .Net Bitmap with Win32 Api calls? Thanks alot
Why would you want to? GDI+ (encapsulated in the
System.Drawing
classes) gives you all the functionality as GDI (though some things are still easier in GDI at times) and all the printing facilities in .NET allow you to manipulate the image that is printed (including text) however you want. It's a heck of a lot easier, especially since coordinate transformations are a little easier since the printer-specific coordinate mapping is abstracted away. If you want to use Win32 printing APIs (which is really just GDI using theHDC
of a printer), then find an example in C/C++ and go to all the work of P/Invoking what you need to do it in C#.Microsoft MVP, Visual C# My Articles
-
Why would you want to? GDI+ (encapsulated in the
System.Drawing
classes) gives you all the functionality as GDI (though some things are still easier in GDI at times) and all the printing facilities in .NET allow you to manipulate the image that is printed (including text) however you want. It's a heck of a lot easier, especially since coordinate transformations are a little easier since the printer-specific coordinate mapping is abstracted away. If you want to use Win32 printing APIs (which is really just GDI using theHDC
of a printer), then find an example in C/C++ and go to all the work of P/Invoking what you need to do it in C#.Microsoft MVP, Visual C# My Articles
The reason that I want to use API is because I am working on a project to print invoices. The .Net printing framework is to slow to keep up with the volume of invoices printed every night. So, my only other alternative is to print using the API. Thanks for your help.
-
The reason that I want to use API is because I am working on a project to print invoices. The .Net printing framework is to slow to keep up with the volume of invoices printed every night. So, my only other alternative is to print using the API. Thanks for your help.
By the time the performance hit for marshaling parameters for P/Invoked method invocation, you probably won't notice a huge difference anyway. Perhaps a better solution is an N-tier design, one in which reports are generated and placed in a directory where another app (or even if the printer "driver" supports such a thing) is responsible only for printing the queued reports and removing them or backing them up. This would be truly faster so that your reporting app can just worry about generating these reports from the onslaught of all this data without having to wait for the printer queue to free-up after a few pages go in. A good multi-threaded design would help, but eventually you'd have to start blocking for sake of memory and performance.
Microsoft MVP, Visual C# My Articles
-
Does anybody know how I could print a .Net Bitmap with Win32 Api calls? Thanks alot
-
By the time the performance hit for marshaling parameters for P/Invoked method invocation, you probably won't notice a huge difference anyway. Perhaps a better solution is an N-tier design, one in which reports are generated and placed in a directory where another app (or even if the printer "driver" supports such a thing) is responsible only for printing the queued reports and removing them or backing them up. This would be truly faster so that your reporting app can just worry about generating these reports from the onslaught of all this data without having to wait for the printer queue to free-up after a few pages go in. A good multi-threaded design would help, but eventually you'd have to start blocking for sake of memory and performance.
Microsoft MVP, Visual C# My Articles
That wouldn't work because I only have a certain block of time that the reports can print because the printer is used for other purposes and with the .Net printing framework, it is constantly going behond that block. It is not the report generation that is slowing down the process, it is the actual printing of the reports. And actually, I am almost done with the Win32 Api printing functions and it seems to be considerably faster.
-
Why are you posting as Anonymous, you don't want anybody to know who you are?