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. How could print a line without ending the page?

How could print a line without ending the page?

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • S Offline
    S Offline
    shooterlily
    wrote on last edited by
    #1

    I want to do some printing randomly, each time print a single line. When I use EndDoc() or Escape(ENDDOC), the printer ends a page. How could I do printing like the POS terminal printer?

    R B 2 Replies Last reply
    0
    • S shooterlily

      I want to do some printing randomly, each time print a single line. When I use EndDoc() or Escape(ENDDOC), the printer ends a page. How could I do printing like the POS terminal printer?

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      When printing, anything rendered to the printer HDC between calls to the StartPage()/EndPage() calls will be printed for that page (as long as its on the actual printable area). So you would be doing something like:

      StartDoc()
      while (pages_to_print)
      {
      StartPage()
      while (output_for_this_page)
      {
      print_a_line
      }
      EndPage()
      }
      EndDoc()

      If you need to print like a terminal, you need to keep track of the current Y position on the page. After every line printed, you increment y value by the height of the line. When y > pageHeight, you end the current page and start a new one.

      StartDoc()
      while (pages_to_print)
      {
      StartPage()
      y = 0
      while (output_for_this_page)
      {
      print_a_line at 0,y
      y += lineHeight
      }
      EndPage()
      }
      EndDoc()

      Roger Allen - Sonork 100.10016 If your dead and reading this, then you have no life!

      S 1 Reply Last reply
      0
      • S shooterlily

        I want to do some printing randomly, each time print a single line. When I use EndDoc() or Escape(ENDDOC), the printer ends a page. How could I do printing like the POS terminal printer?

        B Offline
        B Offline
        Brian Shifrin
        wrote on last edited by
        #3

        StartDoc / EndDoc - designed to protect multipage documents from interspersed with others. PrintJob is suspended until EndDoc is called. >How could I do printing like the POS terminal printer? For remote spoolers - you can not, should not, and will not be allowed to; local - open device e.g. par port/usb and write directly. Even if local with direct write it still likely not work with most modern printers: laser printers, etc .... Brian

        1 Reply Last reply
        0
        • R Roger Allen

          When printing, anything rendered to the printer HDC between calls to the StartPage()/EndPage() calls will be printed for that page (as long as its on the actual printable area). So you would be doing something like:

          StartDoc()
          while (pages_to_print)
          {
          StartPage()
          while (output_for_this_page)
          {
          print_a_line
          }
          EndPage()
          }
          EndDoc()

          If you need to print like a terminal, you need to keep track of the current Y position on the page. After every line printed, you increment y value by the height of the line. When y > pageHeight, you end the current page and start a new one.

          StartDoc()
          while (pages_to_print)
          {
          StartPage()
          y = 0
          while (output_for_this_page)
          {
          print_a_line at 0,y
          y += lineHeight
          }
          EndPage()
          }
          EndDoc()

          Roger Allen - Sonork 100.10016 If your dead and reading this, then you have no life!

          S Offline
          S Offline
          shooterlily
          wrote on last edited by
          #4

          But if I do not call EndPage() or EndDoc(),I could not get the line. I want to see something printed when I print a line. How? Thank u!

          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