Sonntag, 9. Dezember 2007

Use of Printers/Trays/Papers with Rave

Today I'll describe the basics of printer-control in a Delphi application with Rave (possible with all versions of Rave 3.x-7.x and BE/BEX!).

A lot of Rave-user haven't realize that Rave can manage the destination of the print result with out the way of the printer-class, especially the choice of the bin/tray ...

Of course, you can use function like the following to read out the tray from you printer-driver and develop a solution
....
GetPrinter(ADevice,ADriver,APort,hDMode);
pDevMode := nil;
Res := DeviceCapabilities(ADevice,APort,DC_BINNAMES,PCHAR(@(bin[0][0])),pDevMode);
....

But there is an easier way with Rave.
Nevrona Designs have built a "Printer device manager class" called RpDevice.
Insert RpDevice in your uses and then you can work with RpDev.
This function return the current RPDevice object for manage the printer in your app.

RpDev.InvalidPrinter is the first command and with this you can check on the user-machine if there is a correct printer installed or not, e.g. on some servers with running applications aren't installed any printer.

RpDev.Device shows the (selected) printer and RpDev.Printers shows the installed printers on the system.
RpDev.Bins read the installed trays for the selected printer.
RpDev.Papers for the papers (from the driver)

I use Duplex-Mode where ever I can...
With RpDev.SupportDuplex exits an easy way to check if the printer(driver) support duplex or not...

The previous commands only read informations, with RpDev.Select... you can define the destination printer, tray, paper and more

RpDev.SelectPrinter(ComboBox1.Text, true);

To save properties on the printer in the OS you can use RpDev.SaveToPrinter;

Before you execute a report you should define all the things in your code and the result is as expected .

In the RpDev-class you'll find many more and I hope I've opened the door to the possibilities!