Ver Mensaje Individual
  #4  
Antiguo 24-02-2012
Avatar de newtron
[newtron] newtron is offline
Membrillo Premium
 
Registrado: abr 2007
Ubicación: Motril, Granada
Posts: 3.462
Reputación: 21
newtron Va camino a la fama
A ver....

Te pongo un ejemplo de una utilidad para abrir el cajón portamonedas, el corte de papel es exactamente igual solo poniendo los caracteres correspondientes. Lo he simplificado un poco para que te sea más legible.

Código Delphi [-]
// ****************************************************************************
// Rutina      : AbreElCajon
// Descripcion :
// ****************************************************************************
procedure AbreElCajon(var Impreso: TImpreso);

  function CreaLinea: String;
  var
    sAux: String;
  begin

    Result := '';

    sAux := Trim(DlgPropiedades.ComandoAperturaCajon);
    while Pos(' ', sAux) > 0 do begin

      try
        Result := Result + Chr(StrToInt(Copy(sAux, 1, Pos(' ', sAux)-1)));
      except

      end;

      sAux := TrimLeft(Copy(sAux, Pos(' ', sAux)+1, Length(sAux)));

    end;

    try
      Result := Result + Chr(StrToInt(sAux));
    except

    end;

  end;

var
  DocInfo1: TDocInfo1;
  Handle:   THandle;
  Linea:    String;
  N:        DWORD;
begin

    if not OpenPrinter(PChar(Printer.Printers[Impreso.Impresora]), Handle, nil) then begin
      ShowMessage('Error en OpenPrinter : ' + Printer.Printers[Impreso.Impresora]);
      Exit;
    end;

  end;

  with DocInfo1 do begin
    pDocName    := PChar(Impreso.Nombre);
    pOutputFile := nil;
    pDataType   := 'RAW';
  end;

  StartDocPrinter(Handle, 1, @DocInfo1);

  StartPagePrinter(Handle);

//  Linea := #27 + #112 + #0 + #127 + #127;
  Linea := CreaLinea;
  WritePrinter(Handle, PChar(Linea), Length(Linea), N);

  EndPagePrinter(Handle);

  EndDocPrinter(Handle);

  ClosePrinter(Handle);

end;

Espero que te ayude.

Saludos
__________________
Be water my friend.
Responder Con Cita