Re: Controling printers at a detailed level



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
.



Relevant Pages

  • adjusting fonts to computers dpi settings
    ... I have noticed that increasing dpi to 120 or even more does not ... have any effect on Microsoft's windows such as Control Panel and the ... programs within it) or Windows Explorer. ... However my app fonts (checkbox captions, texboxes, command boxes captions ...
    (microsoft.public.vb.general.discussion)
  • Re: monitoring the taskbar in windows
    ... Is there a bulit in class that can directly control the open ... aplications in windows?. ... ROBOT and this could control the windows as neccisary because ROBOT ...
    (comp.lang.java.help)
  • monitoring the taskbar in windows
    ... Is there a bulit in class that can directly control the open ... aplications in windows?. ... having to maximise or minimise the window. ...
    (comp.lang.java.programmer)
  • monitoring the taskbar in windows
    ... Is there a bulit in class that can directly control the open ... aplications in windows?. ... having to maximise or minimise the window. ...
    (comp.lang.java.help)
  • Creating ActiveX control in .NET for IE - Ambient Properties
    ... I am creating an ActiveX control in .NET that is embedded into a web ... I am embedding an ActiveX rather than a Windows Forms ... I would like the font's to be the fonts used in the ...
    (microsoft.public.dotnet.framework.interop)