Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Getting the -REAL- printable area of a page

Getting the -REAL- printable area of a page

Scheduled Pinned Locked Moved C / C++ / MFC
questionlearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Ernesto D
    wrote on last edited by
    #1

    Hi all, to get the real printable area of a page (on a printer of course) is it correct to do it like this? assuming that i want to use HIMETRIC, mydc is a device context (CDC class), and it has allready been "opened" to my printer... dc.SetMapMode(MM_HIMETRIC); CSize pagesize; // get the "physical" size of the page... pagesize.cx=dc.GetDeviceCaps(PHYSICALWIDTH); pagesize.cy=dc.GetDeviceCaps(PHYSICALHEIGHT); // now take off the non printable area pagesize.cx-=dc.GetDeviceCaps(PHYSICALOFFSETX); pagesize.cy-=dc.GetDeviceCaps(PHYSICALOFFSETY); // returned values were in device units, we need himetric dc.DPtoHIMETRIC(&pagesize); // pagesize now has the real printable area of the page is this correct? is there a better way? thanks!

    B 1 Reply Last reply
    0
    • E Ernesto D

      Hi all, to get the real printable area of a page (on a printer of course) is it correct to do it like this? assuming that i want to use HIMETRIC, mydc is a device context (CDC class), and it has allready been "opened" to my printer... dc.SetMapMode(MM_HIMETRIC); CSize pagesize; // get the "physical" size of the page... pagesize.cx=dc.GetDeviceCaps(PHYSICALWIDTH); pagesize.cy=dc.GetDeviceCaps(PHYSICALHEIGHT); // now take off the non printable area pagesize.cx-=dc.GetDeviceCaps(PHYSICALOFFSETX); pagesize.cy-=dc.GetDeviceCaps(PHYSICALOFFSETY); // returned values were in device units, we need himetric dc.DPtoHIMETRIC(&pagesize); // pagesize now has the real printable area of the page is this correct? is there a better way? thanks!

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      In some, if not most cases, I have found that the PHYSICALOFFSETX and PHYSICALOFFSETY would apply to BOTH edges of the page, so you might want to do your math like this: // now take off the non printable area pagesize.cx-= (2 * dc.GetDeviceCaps(PHYSICALOFFSETX)); pagesize.cy-= (2 * dc.GetDeviceCaps(PHYSICALOFFSETY)); I also don't think this accounts for any of the margins the user might have set for the printing area. You might want to also obtain the printer device context (CreateDC) and examine the DEVMODE fields: dmYResolution - Specifies the y-resolution, in dots per inch, of the printer. If the printer initializes this member, the dmPrintQuality member specifies the x-resolution, in dots per inch, of the printer. Or you can get the from associated with a print job and check these fields: Size - Specifies the width and height, in thousandths of millimeters, of the form. ImageableArea - Specifies the width and height, in thousandths of millimeters, of the form.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups