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
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!


Fernando Madruga hat gesagt…

The information is interesting, although the text could use some tuneup: it's a bit "GermanEnglish"... :)

I tried to e-mail you some changes to make the text easier to read, should you want to incorporate them, but I couldn't find any e-mail address... Maybe next time.

Mihaita George hat gesagt…

Hi. I started using Rave (5.0.8 with D7) not so long ago. Because the OutpuOptins screen didnt helped me i made my own. I've added the print option, my preview option, a save to pdf option and a send to email option. I use the RPDev function to modify the printer functionality. The problem i got, beside many others :), is that i'm using a TRvRenderPrinter for printing my report. I just wanna ask: is there any way to print any number of copies i want? It always prints just 1 copie (i use .Render(NDRStream)) and resets the number of copies from my RPDev (wihch i set in my Output Option screen) to 1.

Mihaita George hat gesagt…

And another question. I dont really undertand how RPDev.SaveToPrinter, RPDev.ResetHandler(0) and RPDev.LoadFromPrinter could alter my TRVRenderPrinter functionality.

Anonym hat gesagt…

RpDev.Bins.count is always 0 though
the selected printer definitely has different trays. What could be the reason for this?

Anonym hat gesagt…

Excellent job. Keep publishing posts!

Anonym hat gesagt…

Many thanks for making the effort to write such a beneficial article, it's recently been worthwhile.

Anonym hat gesagt…

It can be sad that you have people out there never browsing this website. Great job

Anonym hat gesagt…

Thanks to you for the content concerning this issue, it turned out very useful.