The PdrStore API can be used to load printer driver information files and
create a printer driver. PdrStore provides access to the printer driver
information contained in .pdr
files for applications to build a
printer driver list. PdrStore also loads and creates an appropriate printer
driver for a given printer.
.pdr
files contain printer driver access information. This
access information can be used by applications to build printer driver lists.
In an unsecure environment, PdrStore provides printer driver lists from the PDR
information files installed in a secure platform environment in the
\resource\printers\
folder.
Load the physical and logical printer device before creating a printer driver. The following code loads the physical and logical devices:
// Load printer driver
User::LoadPhysicalDevice(PDD_NAME);
// Load printer device
User::LoadLogicalDevice(LDD_NAME);
The following code allows you to create a printer driver object, check for the available printer driver models, select a model and create a printer device.
iStopper=new(ELeave) CPdrPrint();
CActiveScheduler::Add(iStopper);
// Create a printer driver object
iDriver=CPrinterDriver::NewL();
TFileName filename( KDriveName );
filename.Append( KDefaultPrinterDriverPath );
filename.Append( KEpsonFileName );
iConsole->Printf ( _L("\nOpening printer driver information file...\n") );
// Open a printer driver information(.pdr) file
TInt ret;
TRAP(ret,iDriver->OpenPdrL( filename ));
if ( ret == KErrNone )
{
iConsole->Printf(_L("\nNumber of models: %d\n"),iDriver->NumModels());
}
// Get models
TPrinterModelEntry entry;
for (TInt i=0; i<iDriver->NumModels(); i++)
{
entry=iDriver->Model(i);
iConsole->Printf(_L("Model: %S\n"),&entry.iModelName);
}
iConsole->Getch();
iConsole->Printf(_L("\nSelect model from 1 to %d\n"),iDriver->NumModels());
iConsole->Printf(_L("\nSelecting... %d\n"),iDriver->NumModels());
iConsole->Printf(_L("\nPrinter driver properties:\n"));
// Create a printer device
iDevice=NULL;
entry=iDriver->Model(iDriver->NumModels()-1);
TRAP(ret,iDevice=iDriver->CreatePrinterDeviceL(entry.iUid));
if ( ret == KErrNone )
{
iConsole->Printf(_L("PDR device: %d\n"),iDevice);
iConsole->Printf(_L("No. of typefaces: %d\n"),iDevice->NumTypefaces());
iConsole->Printf(_L("Model name: %S\n"),&(iDevice->Model().iModelName));
iConsole->Getch();
TPageSpec pagespec(TPageSpec::EPortrait,KA4PaperSizeInTwips);
iDevice->SelectPageSpecInTwips(pagespec);
}