How calculate RECT from emf spool file of printer?
-
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
-
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
The easiest way to do something like this is to take a slightly different approach:
- Use Windows 'Print to file' to produce a file containing the printer driver's output
- 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