Re: Controling printers at a detailed level
- From: "Chris P. [MVP]" <msdn@xxxxxxxxxxxx>
- Date: Tue, 26 Jul 2005 10:19:22 -0400
On Mon, 25 Jul 2005 20:03:45 -0700, Dennis wrote:
> This may be the wrong forum for this question. If there is a better, please
> advise me.
>
> Years ago, in the pre-Windows days, I wrote code to directly control
> printers using ESC sequences (I believe that's what they were called). I
> could get them to TAB, LF and CR and I could adjust various things like
> fonts and font size. All these printer control codes were generally vendor
> specific.
>
> Now, I'd like to do something similar within a Win32 Windows program. I'd
> like to grab control of a laser printer and control page size and line
> height and tab spacing and a raft of things. I want to print labels and
> signs of various sizes and I want a lot of control of the text and imagery
> on them. And I'm a bit puzzled how to start.
>
> Let me say that I've been a Windows C++ Win32 programmer for many years but
> I've never had to wander into the world of printers before.
>
> I suspect that the modern interface to printers has been abstracted so that
> all the vendor specific stuff has gone away. If that's true, then somewhere
> out there are a group of APIs that will allow me to do what I want. I've
> scanned the MSDN library to see what I could find but thus far I've come up
> with a blank. Can someone give me a gentle push in the right direction?
I would avoid direct control. I too used to do that 15 years ago with PCL
and Postscript but it is fraught with danger due to minor differences in
printer models. The reason we have Windows Print drivers is to avoid this
direct and incompatible access and provide a generic interface.
I the Windows Model you can query the printer in a generic way to get
information about margins etc. You create a Device Context (DC) just like
you would for a on-screen Window and draw to it using the exact same
commands. This means all the Windows fonts, and text control are at your
disposal.
MFC can make your life easier here but it's not required. See
CPrintDialog, CPrintDialogEX, CPageSetupDialog, CreateFont,
CreateBrushIndirect, TextOut, ExtTextOut, SetTextAlign, SetTextColor.
Also:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_3y0j.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_3r77.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_9r77.asp
.
- References:
- Controling printers at a detailed level
- From: Dennis
- Controling printers at a detailed level
- Prev by Date: Re: Looping Streamed Audio Using WaveOut
- Next by Date: Re: Looping Streamed Audio Using WaveOut
- Previous by thread: Re: Controling printers at a detailed level
- Next by thread: Re: Controling printers at a detailed level
- Index(es):
Relevant Pages
|