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. Printing problem(print not come on the center of the page)

Printing problem(print not come on the center of the page)

Scheduled Pinned Locked Moved C / C++ / MFC
help
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.
  • A Offline
    A Offline
    a_david123
    wrote on last edited by
    #1

    Respected All Regards! i developed aclass of printing, it works fine but the print did not come on the middle of the page,that's start from the TOP LEFT margine of the page,plz mentioned the changes so that i may able to get the print on the center of the page. Thanks n advance. David david

    N 1 Reply Last reply
    0
    • A a_david123

      Respected All Regards! i developed aclass of printing, it works fine but the print did not come on the middle of the page,that's start from the TOP LEFT margine of the page,plz mentioned the changes so that i may able to get the print on the center of the page. Thanks n advance. David david

      N Offline
      N Offline
      normanS
      wrote on last edited by
      #2

      Following the "brute force and pig-ignorance" approach, I do the following to print an image (C code, but it should give the idea):

      // get the printer height and width
      iPageX = GetDeviceCaps (hdcPrn, HORZRES) ;
      iPageY = GetDeviceCaps (hdcPrn, VERTRES) ;

      // To make neater printouts, make a border of 10%
      iTopMargin = iPageY / 10;
      iLeftMargin = iPageX / 10;

      // Leaving the area we potentially use as follows:
      iPageX = iPageX - iLeftMargin - iLeftMargin;
      iPageY = iPageY - iTopMargin - iTopMargin;

      // ############################################
      // Left out here - do some stuff to get my image and the page into the
      // same aspect ratio
      // ############################################

      // Copy the DI bitmap to the printer
      StretchDIBits(hdcPrn, iLeftMargin, iTopMargin, iPageX , iPageY,
      0, 0, iImageMaxX, iImageMaxY, lvpBits, lpBitMapHeader,
      DIB_RGB_COLORS, SRCCOPY);

      I hope I haven't missed any relevant steps!

      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