CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: Printer Margins

  1. #1
    Guest

    Printer Margins

    How do I get the minimum printer margins? I need to position a label on a page. The user enters the X,Y coordinates of the upper left corner. In order to position this correctly, I need to subtract the printer margins.


  2. #2
    Join Date
    May 2000
    Location
    Scotland, Livingston.
    Posts
    728

    Re: Printer Margins

    Look at the GetDeviceCaps function.
    PHYSICALOFFSETX
    PHYSICALOFFSETY
    PHYSICALWIDTH
    and PHYSICALHEIGHT values for nIndex.


    Dave McLelland
    D. McLelland (Software) Limited
    Dave Mclelland.

  3. #3
    Join Date
    Mar 2009
    Posts
    29

    Re: Printer Margins

    Good Day,

    by using the PHYSICALOFFSETX and PHYSICALOFFSETY i get the "the distance from the left/top edge of the physical page to the left/top edge of the printable area" as noted in MSDN help.

    My question is: how can i find the "right" and "bottom" offsets? Are these the same as their left/top counterparts?

    This would not be an issue if PHYSICALWIDTH and PHYSICALHEIGHT returned the width/height bounds for the printer rather than the page size...

    Thanx in advance,

    Stakon.

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Printer Margins

    Quote Originally Posted by stakon View Post
    This would not be an issue if PHYSICALWIDTH and PHYSICALHEIGHT returned the width/height bounds for the printer rather than the page size...
    The issue is... These values ARE dependant on paper size.

    The printer I'm using at home can print A4 paper up to 4mm from the bottom. But when printing envelopes, it can only handle 12mm from the bottom

    You cannot assume the bottom and right edges of what the printer can handle are universal across all papersizes the printer can handle.

  5. #5
    Join Date
    Mar 2009
    Posts
    29

    Re: Printer Margins

    OReubens,

    I am aware of what you are explaining here. Perhaps the way i wrote the above is confusing...

    What i mean is that PHYSICALWIDTH and PHYSICALHEIGHT return the actual physical paper size
    as explained in http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

    And what i am asking is:
    Can i safely assume that the value returned from PHYSICALOFFSETX (which describes the left printer margin), can be also used as the right printer margin?

    for example:
    left_margin = GetDeviceCaps(PHYSICALOFFSETX);//This IS correct
    right_margin = GetDeviceCaps(PHYSICALWIDTH) - left_margin; //??? is THIS correct ???

  6. #6
    Join Date
    Dec 2008
    Posts
    144

    Re: Printer Margins

    Quote Originally Posted by stakon View Post
    right_margin = GetDeviceCaps(PHYSICALWIDTH) - left_margin; //??? is THIS correct ???
    No, it isn't correct.
    "GetDeviceCaps(PHYSICALWIDTH) - left_margin" gives you the sum of the printable area's width and the right margin.

  7. #7
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Printer Margins

    HORZRES will give you the width of the printable area
    VERTRES will give you the height of the printable area.

  8. #8
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Printer Margins

    Left/Right margins don't need to be identical (although they usually are)
    Bottom and top margins don't need to be identical (and they rarely are).

  9. #9
    Join Date
    Mar 2009
    Posts
    29

    Re: Printer Margins

    Nikitozz,

    i think you are confusing something.
    Let me explain with a numerical example:

    left_margin = GetDeviceCaps(PHYSICALOFFSETX); // = 80 //assume left margin is 80
    page_width = GetDeviceCaps(PHYSICALWIDTH); // = 5000 //assume physical page width is 5000
    right_margin = page_width - left_margin; //5000 - 80 = 4920

    So the result is the right_margin's position is 4920 units from the left of the physical page which is what i am looking for.

    Thanx OReubens for pointing out these (HORZRES ,VERTRES)
    Last edited by stakon; October 15th, 2009 at 06:56 AM.

  10. #10
    Join Date
    Dec 2008
    Posts
    144

    Re: Printer Margins

    Quote Originally Posted by stakon View Post
    So the result is the right_margin's position is 4920 units from the left of the physical page which is what i am looking for.
    Ok. It's clear now. I haven't understand you.
    I thought you wanted to find out the "width" of the margin.

  11. #11
    Join Date
    Jun 2009
    Location
    oklahoma
    Posts
    199

    Re: Printer Margins

    This post was from June 2000!
    I hope the thread starter got it solved by now

  12. #12
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Printer Margins

    Quote Originally Posted by stakon View Post
    right_margin = page_width - left_margin; //5000 - 80 = 4920

    So the result is the right_margin's position is 4920 units from the left of the physical page which is what i am looking for.
    No, because the right margin and left margin are not necessarily the same.

    Left margin is at PHYSICALOFFSETX
    right margin is at PHYSICALOFFSETX + HORZRES
    the width of the right margin is PHYSICALWIDTH - (PHYSICALOFFSETX + HORZRES)

  13. #13
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Printer Margins

    Quote Originally Posted by jnmacd View Post
    This post was from June 2000!
    I hope the thread starter got it solved by now

    Maybe, but someone else (stakon) picked up on it since he has an issue with this also. He SHOULD have made a new thread for this though

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured