> Why do you want to do this? What's in "<filename>"? Are you really
> sending some sort of specific printer commands? Or are you trying to
> replicate the old DOS-style "print a text file" functionality? In your
> original post, you said you want to send printer commands, but copying a
> file to the parallel port isn't a common way to do that.
filename contains "ZPLII" (Zebra Printing Language 2) commands.
Apparently, from what I've read you can either copy a file containing
these commands or write the commands, one line at a time directly to the
printer.
My motivation for sending the commands versus using the .Net printing
(which I'm doing for every other print need in my application) is that
the base64 encoded PNG images from the web service supplying the postage
data is much larger than the printer command data. To clarify; I can
request postage as a bitmap OR as printer commands. The printer
commands option results in quicker turnaround from the service call as
well as the printer starting to print faster.
Another possible option would be to develop a ZPLII parser/renderer but
I highly doubt that would pay off in any way! ;0) (except knowledge gained)
> If the latter, IMHO you might as well just do it the "official" way: use
> the .NET printing API to print your text file. It's not really all that
> complicated and it will be much more general purpose, portable, and
> flexible.
This is my backup plan and the more I'm googling about working with a
USB connected printer the more I'm leaning to this option. There is a
definite point when performance is far out shadowed by nasty hacks and
bloated code.
> If the former, there's a small possibility that whatever you're
> ultimately trying to achieve is dealt with better through some other
> means. If you can give a higher-level description of your goal, maybe
> there'd be better advice.
See first comment for high level description.
> If you are stuck on sending explicit data to the printer, I'd agree with
> Ben that the Win32 direct-to-printer functions are about all you've
> got. AFAIK there's nothing in .NET that would allow that, and this KB
> article seems to verify that: http://support.microsoft.com/kb/322091
> (the article also includes some sample code for sending data in C# using
> WritePrinter() via p/invoke).
This is my next avenue to check out. If I can't make some progress in
the next 4 hours I will abandon the printer command option and opt for
the bitmap/GDI option.
Thanks for the reply,
Steve
Ben Voigt [C++ MVP] - 30 Apr 2008 19:12 GMT
>> If you are stuck on sending explicit data to the printer, I'd agree
>> with Ben that the Win32 direct-to-printer functions are about all
[quoted text clipped - 7 lines]
> the next 4 hours I will abandon the printer command option and opt for
> the bitmap/GDI option.
If you haven't seen this thread then you may want to read through it:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=312732&SiteID=1
> Thanks for the reply,
> Steve