## Printer Device Driver

[prev][next][parent][TOC]

### Function Section

This section contains all prototypes and functions used by the plug-in module either for private use or to be placed in the function hook table.

The following example shows the function the core Omni driver code calls at the beginning of each print job:

    // Function called at beginning of each print job subclassed
    // from the Omni core driver code.

    BOOL  _System SampleBeginJob( PVOID pv, PVOID pvHandle )
    {
       PDDC           pddc       = (PDDC)pv;
       PDEVICEINFO    pDevice    = pddc->pdb->pDevice;
       PSAMPPCLHANDLE pHandle  = (PSAMPPCLHANDLE)pvHandle;

       // If this printer has defined an Initialization command in the
       // plug-in command table.
       if (pDevice->pCmds->ulCmdInit)
       {
          // Send Initialize printer escape codes to output thread
          GplThreadWriteBlock (pddc->pdb->hThread,
                               pDevice->pCmds->pszCmdInit,
                               pDevice->pCmds->ulCmdInit);
       } /* end if */

       // NOTE: Send other escape codes to initialize printer here

       // Set printer's physical head position in our core Omni DDC
       pddc->ptlPrintHead.x = 0;

       // Initialize absolute pel position in core Omni based on orientation
       if (ORIENTATION_PORTRAIT == pddc->pdb->pJobProperties->ulOrientation)
          pddc->ptlPrintHead.y = pddc->pdb->pFormInfo->hcInfo.yPels-1;
       else
          pddc->ptlPrintHead.y = pddc->pdb->pFormInfo->hcInfo.xPels-1;

       // Reset flags for beginning of a new (next) page

       // Reset rendering flag used by GENPLIB dithering code
       // inside DITHERREQUEST structure we store in our Device Handle
       pHandle->Req.SrcOptions.fStartOfPage = TRUE;

       // Initialize a state flag in our Device Handle to indicate
       // Graphics state on printer has not yet been initialized
       pHandle->fHaveSetupPrinter = FALSE;

       return TRUE;

    } /* end SampleBeginJob */

Note: Tailor the required escape codes and variables to your specific printer models.