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 calculate RECT from emf spool file of printer?

How calculate RECT from emf spool file of printer?

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

    I am working on a project intended to control the print flow on the network. User will not be allowed to print on the printer directly. In any case EMF spool file will be generated and parsed and then forwarded to the actual printer(any PS/PCL) printer. For forwarding the print job , I am just taking the destination printer device context and playing the spool file on the destination printer using PlayEnhMetaFile function, so it is printing on paper. Every thing works fine up to this level. But I am getting some problem. The output from print job forwarding and the direct printing to the printer is somewhat differ. I want to get same out put from print job forwarding as I am getting direct printing. For that reason I am counting RECT to play enhanced meta file on the destination printer using following formula. float PixelsX, PixelsY, MMX, MMY; RECT rect; PixelsX = (float)GetDeviceCaps( dc ,HORZRES ); PixelsY = (float)GetDeviceCaps( dc, VERTRES ); MMX = (float)GetDeviceCaps( dc, HORZSIZE ); MMY = (float)GetDeviceCaps( dc, VERTSIZE ); rect.top = (int)((float)(pEMRHeader->rclFrame.top) * PixelsY / (MMY*100.0f)); rect.left = (int)((float)(pEMRHeader->rclFrame.left) * PixelsX / (MMX*100.0f)); rect.right = (int)((float)(pEMRHeader->rclFrame.right) * PixelsX / (MMX*100.0f)); rect.bottom = (int)((float)(pEMRHeader->rclFrame.bottom) * PixelsY / (MMY*100.0f)); Here "dc is Device context for the destination printer" . But each time I am getting somewhat big print from the printer. Is it right way to calculate the RECT? It would be help me if you can look into the problem please. Thank you. Regards, MAhendra

    S 1 Reply Last reply
    0
    • G GAJERA

      I am working on a project intended to control the print flow on the network. User will not be allowed to print on the printer directly. In any case EMF spool file will be generated and parsed and then forwarded to the actual printer(any PS/PCL) printer. For forwarding the print job , I am just taking the destination printer device context and playing the spool file on the destination printer using PlayEnhMetaFile function, so it is printing on paper. Every thing works fine up to this level. But I am getting some problem. The output from print job forwarding and the direct printing to the printer is somewhat differ. I want to get same out put from print job forwarding as I am getting direct printing. For that reason I am counting RECT to play enhanced meta file on the destination printer using following formula. float PixelsX, PixelsY, MMX, MMY; RECT rect; PixelsX = (float)GetDeviceCaps( dc ,HORZRES ); PixelsY = (float)GetDeviceCaps( dc, VERTRES ); MMX = (float)GetDeviceCaps( dc, HORZSIZE ); MMY = (float)GetDeviceCaps( dc, VERTSIZE ); rect.top = (int)((float)(pEMRHeader->rclFrame.top) * PixelsY / (MMY*100.0f)); rect.left = (int)((float)(pEMRHeader->rclFrame.left) * PixelsX / (MMX*100.0f)); rect.right = (int)((float)(pEMRHeader->rclFrame.right) * PixelsX / (MMX*100.0f)); rect.bottom = (int)((float)(pEMRHeader->rclFrame.bottom) * PixelsY / (MMY*100.0f)); Here "dc is Device context for the destination printer" . But each time I am getting somewhat big print from the printer. Is it right way to calculate the RECT? It would be help me if you can look into the problem please. Thank you. Regards, MAhendra

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      The easiest way to do something like this is to take a slightly different approach:

      1. Use Windows 'Print to file' to produce a file containing the printer driver's output
      2. Copy the file to the 'printer port'. This can be a networked printer.

      For example, on the LAN I'm using, there's a printer called 'mint' that's served through a print server called 'greenhouse'. If I print to a file, 'd:\test.prn', the following will cause the file to be correctly printed:

      copy d:\test.prn \\greenhouse\mint

      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