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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC printing extra blank page

MFC printing extra blank page

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
6 Posts 3 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.
  • R Offline
    R Offline
    raytheonthenak
    wrote on last edited by
    #1

    I created an SDI MFC app, and print preview shows the correct range of pages, but when actually printing (on any printer) it will print a trailing blank page. I have overloaded the functions OnPrint, OnBeginPrinting, OnPreparePrinting (for a CRichEditView derived class). Ive tried calculating the value for SetMaxPage() using char heights and lines per document, etc. but it never comes out right. Any suggestions as to how to get the framework to stop printing the extra blank page every time? nak

    C B 2 Replies Last reply
    0
    • R raytheonthenak

      I created an SDI MFC app, and print preview shows the correct range of pages, but when actually printing (on any printer) it will print a trailing blank page. I have overloaded the functions OnPrint, OnBeginPrinting, OnPreparePrinting (for a CRichEditView derived class). Ive tried calculating the value for SetMaxPage() using char heights and lines per document, etc. but it never comes out right. Any suggestions as to how to get the framework to stop printing the extra blank page every time? nak

      C Offline
      C Offline
      CodeBrain
      wrote on last edited by
      #2

      Have you tried different printers?

      1 Reply Last reply
      0
      • R raytheonthenak

        I created an SDI MFC app, and print preview shows the correct range of pages, but when actually printing (on any printer) it will print a trailing blank page. I have overloaded the functions OnPrint, OnBeginPrinting, OnPreparePrinting (for a CRichEditView derived class). Ive tried calculating the value for SetMaxPage() using char heights and lines per document, etc. but it never comes out right. Any suggestions as to how to get the framework to stop printing the extra blank page every time? nak

        B Offline
        B Offline
        basementman
        wrote on last edited by
        #3

        Are your calculations based on the display DC or the printer DC? There is a slight difference. Mainly in that the actual paper size is not the "printable area". Printers have a non-printable margin area (on laserjets, usually 1/4 inch) that is not addressable. So, your 8 1/2 x 11 paper is really 8 x 10 1/2 printer addressable. See GetDeviceCaps with the opcodes of PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, etc.  onwards and upwards...

        R 1 Reply Last reply
        0
        • B basementman

          Are your calculations based on the display DC or the printer DC? There is a slight difference. Mainly in that the actual paper size is not the "printable area". Printers have a non-printable margin area (on laserjets, usually 1/4 inch) that is not addressable. So, your 8 1/2 x 11 paper is really 8 x 10 1/2 printer addressable. See GetDeviceCaps with the opcodes of PHYSICALWIDTH, PHYSICALHEIGHT, PHYSICALOFFSETX, PHYSICALOFFSETY, etc.  onwards and upwards...

          R Offline
          R Offline
          raytheonthenak
          wrote on last edited by
          #4

          Yes, Im using DEVICECAPS and other methods to calc the drawable area. The extra page does not print my headers and footers on it, so it must not be calling OnPrint for the last blank page. As per the other response I have tried it on different printers and different documents and it always prints the extra page. I was wondering if theres any way to override OnEndPrint or some "cheap" way to just stop it from spitting out that extra page. (Could the printer be receiving some line feed or something after the actual document that makes it print a blank page?)

          C 1 Reply Last reply
          0
          • R raytheonthenak

            Yes, Im using DEVICECAPS and other methods to calc the drawable area. The extra page does not print my headers and footers on it, so it must not be calling OnPrint for the last blank page. As per the other response I have tried it on different printers and different documents and it always prints the extra page. I was wondering if theres any way to override OnEndPrint or some "cheap" way to just stop it from spitting out that extra page. (Could the printer be receiving some line feed or something after the actual document that makes it print a blank page?)

            C Offline
            C Offline
            CodeBrain
            wrote on last edited by
            #5

            Yes it seems that the printer gets some extra line feed or something like that. If the print preview is ok, it seems to be a hardware problem. Did you try your program on an other PC? You may also check how often your OnPrint method is called during printing.

            R 1 Reply Last reply
            0
            • C CodeBrain

              Yes it seems that the printer gets some extra line feed or something like that. If the print preview is ok, it seems to be a hardware problem. Did you try your program on an other PC? You may also check how often your OnPrint method is called during printing.

              R Offline
              R Offline
              raytheonthenak
              wrote on last edited by
              #6

              Actually its nothing like that. If you research the MFC underlying infrastructure, the CPrintInfo object has default min, max page values of 1 & 0xFFFF respectively. Thus when printing it will print to those pages, until it encounters a page with no data. As far as Ive found the only way to get rid of this is to SetMaxPage to the correct number of pages. But the textmetrics & sizes that some Printer DeviceContexts return to you arent correct, so Im still having problems determining exactly how to calculate this. Also strangely, in my font, the boldface char's seem to take up barely more space than the regular ones. Im still working on this problem, so Im not sure what the solution is yet

              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