Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



How to create a .pdl file

A .pdl file is a plugin DLL. The DLL must:


The CFbsDrvDevice-derived class

A new printer device is defined by a CFbsDrvDevice derived class.

CFbsDrvDevice is derived from CPdrDevice and implements functionality for a printer driver.

CPdrDevice is an internal class that simply provides an implementation for functions defined in its base classes. CFbsDrvDevice is the usual base class for concrete printer device classes.

Printer drivers must implement a CreateControlL() function. This should create the printer control, (an instance of the CPdrControl derived class), which is used to control the progress of the printing of pages. The argument passed to this function is the port on which the printer is found.

For example, the EPSON printer driver implements this as:

void CEpsonDevice::CreateControlL(CPrinterPort* aPrinterPort)
    {
    __ASSERT_ALWAYS(aPrinterPort,Panic(EEpsonRequiresPrinterPort));
    __ASSERT_ALWAYS(!iControl,Panic(EEpsonControlAlreadyExists));
     __ASSERT_DEBUG(iCurrentPageSpecInTwips.iPortraitPageSize.iWidth && iCurrentPageSpecInTwips.iPortraitPageSize.iHeight,Panic(EEpsonPageSpecNotSet));
    iControl = CEpsonControl::NewL(this,aPrinterPort,*iStore,iModelInfo->iResourcesStreamId);
    }

Consideration should be given to the following points:

[Top]


The CFbsDrvControl-derived class

This class defines the printer control.

CFbsDrvControl is derived from CPdrControl and implements functionality for a printer control.

CPdrControl is an internal class that simply provides an implementation for functions defined in its base classes.

The printing process prints each page as a number of bands:

The printer driver splits up the page into a number of bands, and the print process then processes the bands, starting at the top, outputting the graphics and text for each band. The most important function to be implemented by the derived class is OutputBandL(). This function is called repeatedly during printing, by the printer control's QueueGetBand() function. Its purpose is to place any text or graphics contained within that band into the printer buffer.

Note that any text on the page is prepared before this banded printing process begins - on a notional band 0. Any text is either output to the printer, for page printers which can handle text positioning separately from graphics - e.g. PCL and postscript printers, or is put into a buffer ready for when it is needed later in the banding process.

The MoveToL() function should place in the printer buffer the correct codes to perform a move to a particular point in the band - this is used when there is no graphics drawing to do until that point.

Typically, a derived class will define a static NewL() function to create an instance of the class. For example, for the Epson driver:

CEpsonControl* CEpsonControl::NewL(CPdrDevice* aPdrDevice,CPrinterPort* aPrinterPort,CStreamStore& aStore,TStreamId aResourcesStreamId)
    {
    CEpsonControl* control=new(ELeave) CEpsonControl(aPdrDevice,aPrinterPort);
    CleanupStack::PushL(control);
    control->ConstructL(aStore,aResourcesStreamId);
    CleanupStack::Pop();
    return control;
    }

[Top]


The EPSON class definitions

The following class definitions are for the EPSON driver:

class CEpsonDevice : public CFbsDrvDevice
    {
public:
    CEpsonDevice();
    ~CEpsonDevice();
    void CreateControlL(CPrinterPort* aPrinterPort);
    };

class CEpsonControl : public CFbsDrvControl 
    {
public:
       static CEpsonControl* NewL(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId);
       ~CEpsonControl();

    // print control functions

protected:
       CEpsonControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort);
       void ConstructL(CStreamStore& aStore, TStreamId aResourcesStreamId);

       void OutputBandL();
       void MoveToL(const TPoint& aPoint); 
       TBool TransformBuffer();

protected:
       TBuf8<KEpsonNumScanLinesPerBand >> 3> iScanLine;
       };