1
votes

We have an application that prints 2 invoice copies - 1 on white (for the cust) and 1 on blue (for us).
We print a LOT of these so we are getting a printer with 3 big trays. One tray (tray 5) holds 4000 sheets and the other two (trays 3 and 4) are a tandem set holding 1600 and 2000 sheets. The application automatically generates the invoice and sends one document to the tray with the white paper and one to the tray with the blue paper.

The user has no input in this process.

Now, my problem is this - if I specifically send the blue copy to tray 3 and there is no paper in tray 3, the job will go on hold until someone loads it up even though tray 4 has 2000 more sheets ready to go. On the other hand, if I tell the printer to print on Blue 8 1/2x11" paper, it is smart enough to know that that type of paper is in both trays and to pull from either one until they are both empty. So, I want to change our application to select a paper type/size and color instead of a specific tray.

The program is written in Delphi and I have been looking at the DEVMODE structure returned by TPrinter.GetPrinter. The DEVMODE structure has a memory size in dmDriverExtra that indicates how much extra data the print driver is adding to the structure for its own storage.

Does anyone know of anyway to access this data and make changes to it? If you have examples in other languages, I can probably adapt it to Delphi so anything will help.

1
What do the printer docs say?David Heffernan
@DavidHeffernan: They don't say anything regarding driver data structures. Am I pretty much screwed without this?Caynadian
@whosrdaddy: That article refers to setting the paper size which is a common property among all printers and can be done without driver specific data. The paper color setting that I want to get it is specific to the Xerox printers we're using and is not exposed in the standard DEVMODE structure. Thanks though.Caynadian
you don't have to analyse, just set the properties how you like them in the dialog and then copy over anything that comes after the DEVMODE structure.whosrdaddy

1 Answers

0
votes

There are actually two different items in the questions:

How to set the pater size and type:

  • PaperSize would be stored in dmPaperSize (value DMPAPER_LETTER)
  • PaperType is a bit more difficult. I'd guess that it's in dmMediaType (use DeviceCapabilities to retrieve available media types and their names)

How to access / edit "DriverExtra" data:

In short: don't!

A bit longer: dmDriverExtra is described as "Contains the number of bytes of private driver-data that follow this structure". So this data is private to the driver (which means that you need very good documentation for the driver to actually know the format and content of this data. It's not guaranteed that different versions of the driver use the same format).

So the only thing you can do is to use a print dialog, retrieve the DevMode structure and store it for further use (however as I said: If the driver changes, this data may become invalid...)