• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

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
0
tekwini
Asked:
tekwini
  • 3
  • 2
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
 
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now