Different results on different printers using CDC

I use CDC::TextOut() to print something at x,y co-ords (MM_TEXT mode).  On 90% of printers its fine, but on old HP4's and some others the x and y positioning is way off.

It's a dialog-based app and all I want is a method of applying the same positioning wherever its printed.  As it is now, the same x co-ord produces output at different leftmargin-offsets of the page depending on the printer selected.  y-offsets have a similar problem.

Example : textout(0,0,"stringone"); textout(500,0,"stringtwo");

produces: "stringone         stringtwo" on a lexmark 1020
produces: "stringone    stringtwo"      on a hp4

...although the text itself appears the same on both printers (font size etc is ok).  Im trying to write a label app so positioning is important.

Documentation in this area is pretty fuzzy.

Thanks
Julie Mason

tekwini@bigfoot.com
tekwiniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
>the x and y mean something completely different
>all I want is a method of applying the same scaling wherever its printed

Do you mean coordinates or size?
0
tekwiniAuthor Commented:
Edited text of question.
0
tekwiniAuthor Commented:
Edited text of question.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

nietodCommented:
Please don't edit the question once experts have begin to work on it.  This "destroys" information.  Just post comments.

You should use SetViewPortOrg() and SetWindowOrg() to set the origin to a "known" location.  For example, to set the origin to the top-left corner of the page.

continues.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nietodCommented:
For example, you can set the vewport origin like

const int MarginWidth = GetDeviceCaps(hDC,PHYSICALOFFSETX):
const int MarginHeight = GetDeviceCaps(hDC,PHYSICALOFFSETY):

SetViewPortOrgEx(hDC,-1*MarginWidth,-1*MarginHeight,NULL);

This sets the viewport origin to the top-left corner of the page.  Now this is probably an area that can't be printed to, but that is okay.   You just must be sure to print far enough to the right of the left margin area and far enough below the top margin that you output can appear on any "reasonable" printer.

Let me explain that a  little better.  The DC is originall set so that the viewport origin is the top-left most pixel that can be printed to.  So its position on the page depends on the printer's margins.  But moving the viewport origin to a particular position on the page, (I chose the top-left corner, it could be any other) you can now position the output to a particular spot on the page.  However, you know longer know if a particular position is one that will be able to actually print or not.

Make sense?

You are reasnabley safe if you assume that a page printer has a 1/4 inch border on the top, left, and right sides and a 3/4 inch border on the bottom that cannot be printed in.  So position your ouput so that it does not extend into this border and you should bo okay for almost all page printers.

Let me know if you have any questions.
0
tekwiniAuthor Commented:
Thanks nietod :)  Im all fixed.

I now have a much more solid printing routine that now prints the same on all the printers I usually come accross, and supports more mapping modes just in case I find a strange one in the future.

I also have a better understanding of device drawing in general.

Thanks again!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.