.pdl
file
A .pdl
file is a plugin DLL. The DLL must:
implement a class derived from CFbsDrvDevice
implement a class derived from CFbsDrvControl
export a function at the ordinal 1 position that creates, and returns
a pointer to, an instance of the derived device class. This allows an instance
of the printer driver to be created and controlled by the application wishing
to print. By convention, this exported function is named
NewPrinterDeviceL()
and is prototyped as:
CPrinterDevice* NewPrinterDeviceL();
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:
The KPixelSizeInTwips()
member function implemented by
CFbsDrvDevice
returns the pixel size of the printer device; taking
no account of the orientation, (landscape or portrait). Where this assumption
is not true, this function needs to be overridden in the derived class.
The default implementation is:
EXPORT_C TSize CFbsDrvDevice::KPixelSizeInTwips() const
{
return TSize(iModelInfo->iKPixelWidthInTwips, iModelInfo->iKPixelHeightInTwips);
}
A constructor and a destructor may be required, depending on the needs of the printer driver 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;
}
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;
};