Thursday, June 5, 2014

Set paper length for tape(Label) printer ( EPSON OK900P )

procedure TForm1.Button1Click(Sender: TObject);
var
  Device :Array [0..255] of char;
  Driver :Array [0..255] of char;
  Port : Array [0..255] of char;
  hDMode : THandle;
  PDMode : PDEVMODE;

begin
  Printer.PrinterIndex := Printer.PrinterINdex;
  Printer.GetPrinter(Device,Driver,Port,hDMode);
  if hDMode <> 0 then
  begin
      pDMode := GlobalLock(hDMode);
      if pDMode <> nil then
      begin
        pDMode^.dmFields := pdMOde^.dmFields or DM_PAPERLENGTH;// or DM_PAPERWIDTH or DM_PAPERSIZE;

        pDMode^.dmPaperLength := 400;   // millimiter x 10;

        pdMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
        pDMode^.dmDefaultSource := DMBIN_MANUAL;
        GlobalUnlock(hDMode);
      end;
  end;

  Printer.PrinterIndex := Printer.PrinterIndex;

  Printer.BeginDoc;
  with Printer.Canvas
  do
  begin

    Ellipse(0,0,Printer.PageWidth, Printer.PageHeight);
  end;
  Printer.EndDoc;
end;

No comments:

Post a Comment