Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to create a .pdl file

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


The CPdrDevice-derived class

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

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

CPdrDevice is an internal class that simply provides an implementation for functions defined in its base classes. However, printer drivers must provide the following:

Consideration should be given to the following points:

[Top]


The CPdrControl-derived class

This class defines the printer control.

CPdrControl is derived from CPrinterControl 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 as the following drawing shows:

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 separate 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.

The SetPageSizeL() function should specify the area of the page which the printer can physically print, i.e. the print margins.

Typically, a derived class will define a static NewL() function to create an instance of the class. This will take the set of parameters of type CPdrDevice*, CPrinterPort*, CStreamStore&, TStreamId. 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 CPdrDevice
    {
public:
    CEpsonDevice();
    ~CEpsonDevice();
    TInt CreateContext(CGraphicsContext*& aGC);
    void CreateControlL(CPrinterPort* aPrinterPort);
protected:
    TSize KPixelSizeInTwips() const;
    };

class CEpsonControl : public CPdrControl
    {
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();
    void SetPageSizeL();
    protected:
    TBuf8<KEpsonNumScanLinesPerBand>>3> iScanLine;
    };