Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Initializing Printer using PJL commands

edited July 2002 in General
I have a report that prints 2 copies of an invoice, each copy can be more
than one page. The first copy selects pre-printed paper from bin 1 and the
second copy plain paper from bin 2. I can get this to work using the
OnPageStart event and setting the PrinterSetup.BinName property. Not sure
if this is the best way but could not find an event that is triggered by the
second copy.

The problem that I can't find a way around is the printer I am using has a
feature to staple the two copies together. There is a PJL (Printer Job
Language) command to do this but I don't know how to initialize the printer
using this command. How can I send a control sequence to the printer before
running the report?

Any help much appreciated!

Stephen Bedford

Comments

  • edited July 2002
    It appears that the old ESCAPE Win API and the 'new' GDI calls are simply
    not compatible. The main problem appears to be that, if you are making
    real-time ESCAPE calls to the printer and spooled document calls via the
    GDI, then the spooled document calls are the only ones which have any
    effect - since these are sent after the ESCAPE calls and thus override any
    settings made by the ESCAPE calls. We may have a breakthrough at some
    point, but that is the status right now.

    implementation

    uses
    Windows;

    type

    TBuffer = record
    Length: Word;
    Buffer: array[0..255] of Char;
    end;

    procedure TForm1.Report1OnStartFirstPass(Sender: TObject);
    var
    lCanvas: TCanvas;
    lsEscapeCode: String;
    begin

    if not(ppReport1.PrinterDevice <> nil) then
    begin
    lCanvas := ppReport1.PrinterDevice.Printer.Canvas;
    lsEscapeCode:= {your code here}

    SendEscapeCode(lCanvas, lsEscapeCode);
    end;

    end;



    procedure SendEscapeCode(aCanvas: TCanvas; aEscapeCode: String);
    var
    lBuffer: TBuffer;
    lPassThrough: Integer;
    begin

    lPassThrough := PASSTHROUGH;

    if (Escape(aCanvas.Handle, QUERYESCSUPPORT, SizeOf(lPassThrough),
    @lPassThrough, nil) > 0) then
    begin
    StrPCopy(lBuffer.Buffer, aPassThroughCode);
    lBuffer.Length := StrLen(lBuffer.Buffer);

    Escape(aCanvas.Handle, PASSTHROUGH, 0, @lBuffer, nil);
    end;

    end;


    Cheers,

    Jim Bennett
    Digital Metaphors Corp.

This discussion has been closed.