LX 300, Avanço para o corte do papel.

29/10/2008

0

Olá amigos!
Recentemente me deparei com o problema de não conseguir que um documento impresso direto na porta da impressora ,LPT1 por exemplo, termine de forma que a impressora ejete o papel para a posição de corte na tampa, ressaltando que as configurações ja foram feitas na impressora, ela esta com otamanho de papel desejado e com auto-tear-off on.
Quando uso os botões da impressora ela ejeta o papel da forma certa, porém quando mando um documento e ejeto a página pelo delphi com o comando #12 ela ejeta porém não coloca o papel na posição de corte.

Eu imagino que exista um comando ja que um aplicativo que roda na empresa de meu cliente funcina certinho.

Caso alguém possa me ajudar eu ficarei muito grato.


Desenvolvedor2

Desenvolvedor2

Responder

Posts

29/10/2008

Jc

bem legal isso, nem sei como funciona, mas gostaria muito de saber como ejetar o papel para o corte...

Ajude ai gente...


Responder

29/10/2008

Ffabiop

Então dessa vez vai 2 enduvidados(isso existe?) com uma dica só:
Tem que configurar no setup da impressora a opção corte automático do papel(mãeee!!! cade o maual da impressora?). Desliga ela e liga pressinando o botão pause acho, e boa programação de LX-300! Desconheço a existência de um ´comando´.


Responder

30/10/2008

Emerson Nascimento

você tentou #2712 ou somente 12 ?

tente também:
2725´C´

272567

27´J´

29´E´


lembrando que nem todas as impressoras aceitam esse comando via código. algumas aceitam somente o pressionamento da tecla do painel.


Responder

10/11/2008

Desenvolvedor2

Olá amigo, tentei todos os comandos sugeridos e não consegui.

Estou com todos os comandos em um documento enviado pela EPSON
porém não funcionan.

Valeu pela dica.


Responder

12/11/2008

Desenvolvedor2

Olá galera!

Consegui resolver meu problema de auto tear off criando um arquivo txt e o enviando para para a impressora via print.
Ex:
winexec(pchar(´print /d:LPT1 c:\filename.txt´),0);

Funcionou certinho, só tenho um problema, não funciona no windows 98, não encontrei o aplicativo Print.exe em nehuma maquina com windows 98, me parece que a nativo dos sistemas NT.

Se alguém já tiver passado por isso e puder me ajudar!

Um abraço!


Responder

12/11/2008

Desenvolvedor2

Olá amigo!
Não funcionaram, nenhum dos comandos acima.

Eu tenho aqui um link para um arquivo com todos os comandos da Epson
tentei todos e não consegui fazer funcionar o tear off, lembrando que a impressora ja está configurada com papel de 5.5 Pol e auto tear off em on, todos os documentos que mando funcionam certinho exeto os mandados por writeln.

Segue o link para o arquivo da Epson
[/url]http://www.box.net/shared/todvm5l9et[url]

Vamos achar a resposta juntos galera.

Um abraço[/url]


Responder

12/11/2008

Leonardo_age

Amigo aqui na empresa usamos o componente RDPrint (só acho que é pago) e não temos esse problema. Nele você configura a quantidade de linhas e de colunas da pagina, e envia comando linha a linha, mas é bem simples!

E o melhor é que ele não tem que ser configurado para uma impressora específica, qualquer matricial imprime tranquilo até mesmo as mini-imprissoras.

Segue o link para você dar uma pesquisada: www.deltress.com.br


Abraços


Responder

17/11/2008

Desenvolvedor2

Olá amigos!
Valeu pela força!

O meu problema foi resolvido, eu estava trabalhando com uma variável do tipo TextFile.

Exemplo:

procedure TForm1.Button1Click(Sender: TObject);
const
cEject = #12;
var
Texto: string;
F: TextFile;
begin
AssignFile(F,´c:\filename.txt´);
Rewrite(F);
try
Write(F,EscDraft+EscCondensedOn);
WriteLn(F,´teste de impressão´);
WriteLn(F,´teste de impressão´);
WriteLn(F,´teste de impressão´);
WriteLn(F,´teste de impressão´);
WriteLn(F,´teste de impressão´);
WriteLn(F,´teste de impressão´);
WriteLn(F,12); // Usado para ejetar a folha no tamanho configurado
WriteLn(F,29´E´); //Preciso de um comando aqui para o ´tear off´ funcionar.
finally
CloseFile(F);
end;
winexec(pchar(´print /d:LPT1 c:\filename.txt´),0);
end;


Com o código o código acima, todos os caracteres de controle que eu testei não funcionaram.



Agora eu uso uma unit divulgada aqui no site, que não trabalha com o tipo Textfile o seu nome é [b:8375efc177]CharPrinter[/b:8375efc177].


//---------------------------------------------------------------
// CharPrinter.pas - Tratamento de impressoras em modo caractere
//---------------------------------------------------------------
// Autor : Fernando Allen Marques de Oliveira
// Dezembro de 2000.
//
// TPrinterStream : classe derivada de TStream para enviar dados
// diretamente para o spool da impressora sele-
// cionada.
//
// TCharPrinter : Classe base para implementação de impressoras.
// não inclui personalização para nenhuma impres-
// sora específica, envia dados sem formatação.
//
// Modificado em 20/05/2003 - Compatibilização com diretivas padrão do Delphi 7

unit CharPrinter;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Printers, WinSpool;

type
{ Stream para enviar caracteres à impressora atual }
TPrinterStream = class (TStream)
private
fPrinter : TPrinter;
fHandle : THandle;
fTitle : String;
procedure CreateHandle;
procedure FreeHandle;
public
constructor Create (aPrinter: TPrinter; aTitle : String);
destructor Destroy; override;
function Write (const Buffer; Count : Longint): Longint; override;
property Handle : THandle read fHandle;
end;

TCharPrinter = class(TObject)
private
{ Private declarations }
fStream : TStream;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
constructor Create; virtual;
destructor Destroy; override;
procedure OpenDoc (aTitle : String); virtual;
procedure SendData (aData : String);
procedure CloseDoc; virtual;
property PrintStream : TStream read fStream;

end;

// Definições para TAdvancedPrinter //

TprtLang = (lngEPFX,lngESCP2,lngHPPCL);
TprtFontSize = (pfs5cpi,pfs10cpi,pfs12cpi,pfs17cpi,pfs20cpi);
TprtTextStyle = (psBold,psItalic,psUnderline);
TprtTextStyles = set of TprtTextStyle;

TAdvancedPrinter = class (TCharPrinter)
private
fLang : TprtLang;
fFontSize : TprtFontSize;
fTextStyle : TprtTextStyles;
function GetLang : TprtLang;
procedure SetFontSize (size : TprtFontSize);
function GetFontSize : TprtFontSize;
procedure SetTextStyle (styles : TprtTextStyles);
function GetTextStyle : TprtTextStyles;
procedure UpdateStyle;
procedure Initialize;
function Convert (s : string) : string;
public
procedure CR;
procedure LF; overload;
procedure LF (Lines : integer); overload;
procedure CRLF;
procedure FF;
procedure Write (txt : string);
procedure WriteLeft (txt, fill : string; size : integer);
procedure WriteRight (txt, fill : string; size : integer);
procedure WriteCenter(txt, fill : string; size : integer);
procedure WriteRepeat(txt : string; quant : integer);
procedure SetLang (lang : TprtLang);
published
constructor Create; override;
procedure OpenDoc (aTitle : String); override;
property Language : TprtLang read GetLang write SetLang;
property FontSize : TprtFontSize read GetFontSize write SetFontSize;
property TextStyle : TprtTextStyles read GetTextStyle write SetTextStyle;
end;

procedure Register;

implementation

procedure Register;
begin
{ RegisterComponents(´AeF´, [TCharPrinter]);}
end;

{ =================== }
{ = TPrinterStream = }
{ =================== }

constructor TPrinterStream.Create (aPrinter : TPrinter; aTitle : String);
begin
inherited Create;
fPrinter := aPrinter;
fTitle := aTitle;
CreateHandle;
end;

destructor TPrinterStream.Destroy;
begin
FreeHandle;
inherited;
end;

procedure TPrinterStream.FreeHandle;
begin
if fHandle <> 0 then
begin
EndPagePrinter (fHandle);
EndDocPrinter (fHandle);
ClosePrinter (Handle);
fHandle := 0;
end;
end;

procedure TPrinterStream.CreateHandle;
type
DOC_INFO_1 = packed record
pDocName : PChar;
pOutputFile : PChar;
pDataType : PChar;
end;
var
aDevice,
aDriver,
aPort : array[0..255] of Char;
aMode : Cardinal;
DocInfo : DOC_INFO_1;
begin
DocInfo.pDocName := nil;
DocInfo.pOutputFile := nil;
DocInfo.pDataType := ´RAW´;

FreeHandle;
if fHandle = 0 then
begin
fPrinter.GetPrinter (aDevice, aDriver, aPort, aMode);
if OpenPrinter (aDevice, fHandle, nil)
then begin
DocInfo.pDocName := PChar(fTitle);
if StartDocPrinter (fHandle, 1, @DocInfo) = 0
then begin
ClosePrinter (fHandle);
fHandle := 0;
end else
if not StartPagePrinter (fHandle)
then begin
EndDocPrinter (fHandle);
ClosePrinter (fHandle);
fHandle := 0;
end;
end;
end;
end;

function TPrinterStream.Write (const Buffer; Count : Longint) : Longint;
var
Bytes : Cardinal;
begin
WritePrinter (Handle, @Buffer, Count, Bytes);
Result := Bytes;
end;

{ ================= }
{ = TCharPrinter = }
{ ================= }

constructor TCharPrinter.Create;
begin
inherited Create;
fStream := nil;
end;

destructor TCharPrinter.Destroy;
begin
if fStream <> nil
then fStream.Free;
inherited;
end;

procedure TCharPrinter.OpenDoc (aTitle : String);
begin
if fStream = nil
then fStream := TPrinterStream.Create (Printer, aTitle);
end;

procedure TCharPrinter.CloseDoc;
begin
if fStream <> nil
then begin
fStream.Free;
fStream := nil;
end;
end;

procedure TCharPrinter.SendData (aData : String);
var
Data : array[0..255] of char;
cnt : integer;
begin
for cnt := 0 to length(aData) - 1 do
Data[cnt] := aData[cnt+1];

fStream.Write (Data, length(aData));
end;

{ ===================== }
{ = TAdvancedPrinter = }
{ ===================== }

procedure TAdvancedPrinter.SetLang (lang : TprtLang);
begin
fLang := lang;
end;

function TAdvancedPrinter.GetLang : TprtLang;
begin
result := fLang;
end;

procedure TAdvancedPrinter.SetFontSize (size : TprtFontSize);
begin
fFontSize := size;
UpdateStyle;
end;

function TAdvancedPrinter.GetFontSize : TprtFontSize;
begin
result := fFontSize;
UpdateStyle;
end;

procedure TAdvancedPrinter.SetTextStyle (styles : TprtTextStyles);
begin
fTextStyle := styles;
UpdateStyle;
end;

function TAdvancedPrinter.GetTextStyle : TprtTextStyles;
begin
result := fTextStyle;
UpdateStyle;
end;

procedure TAdvancedPrinter.UpdateStyle;
var
cmd : string;
i : byte;
begin
cmd := ´´;
case fLang of
lngESCP2, lngEPFX : begin
i := 0;
Case fFontSize of
pfs5cpi : i := 32;
pfs10cpi : i := 0;
pfs12cpi : i := 1;
pfs17cpi : i := 4;
pfs20cpi : i := 5;
end;
if psBold in fTextStyle then i := i + 8;
if psItalic in fTextStyle then i := i + 64;
if psUnderline in fTextStyle then i := i + 128;
cmd := #27´!´+chr(i);
end;
lngHPPCL : begin
Case fFontSize of
pfs5cpi : cmd := 27´(s5H´;
pfs10cpi : cmd := 27´(s10H´;
pfs12cpi : cmd := 27´(s12H´;
pfs17cpi : cmd := 27´(s17H´;
pfs20cpi : cmd := 27´(s20H´;
end;
if psBold in fTextStyle
then cmd := cmd + 27´(s3B´
else cmd := cmd + 27´(s0B´;
if psItalic in fTextStyle
then cmd := cmd + 27´(s1S´
else cmd := cmd + 27´(s0S´;
if psUnderline in fTextStyle
then cmd := cmd + 27´&d0D´
else cmd := cmd + 27´&d@´;
end;
end;
SendData(cmd);
end;

procedure TAdvancedPrinter.Initialize;
begin
case fLang of
lngEPFX : SendData (27´@´27´2´27´P´18);
lngESCP2 : SendData (27´@´27´O´27´2´27´C0´1127´!´0);
lngHPPCL : SendData (27´E´27´&l2A´27´&l0O´27´&l6D´27´(s4099T´27´(s0P´27´&k0S´27´(s0S´);
end;
end;

function TAdvancedPrinter.Convert (s : string) : string;
const
accent : string = ´ãàáäâèéëêìíïîõòóöôùúüûçÃÀÁÄÂÈÉËÊÌÍÏÎÕÒÓÖÔÙÚÜÛÇ´;
noaccent : string = ´aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC´;
var
i : integer;
begin
for i := 1 to length(accent) do
While Pos(accent[i],s) > 0 do s[Pos(accent[i],s)] := noaccent[i];
result := s;
end;

constructor TAdvancedPrinter.Create;
begin
inherited Create;
fLang := lngESCP2;
fFontSize := pfs10cpi;
fTextStyle := [];
end;

procedure TAdvancedPrinter.OpenDoc (aTitle : String);
begin
inherited OpenDoc (aTitle);
Initialize;
end;

procedure TAdvancedPrinter.CR;
begin
SendData (#13);
end;

procedure TAdvancedPrinter.LF;
begin
SendData (10);
end;

procedure TAdvancedPrinter.LF (Lines : integer);
begin
while lines > 0 do begin
SendData(#10); dec(lines);
end;
end;

procedure TAdvancedPrinter.CRLF;
begin
SendData (1310);
end;

procedure TAdvancedPrinter.FF;
begin
SendData(12);
end;

procedure TAdvancedPrinter.Write (txt : string);
begin
txt := Convert (txt);
SendData (txt);
end;

procedure TAdvancedPrinter.WriteLeft (txt, fill : string; size : integer);
begin
txt := Convert(txt);
while Length(txt) < size do txt := txt + fill;
SendData (Copy(txt,1,size));
end;

procedure TAdvancedPrinter.WriteRight (txt, fill : string; size : integer);
begin
txt := Convert(txt);
while Length(txt) < size do txt := fill + txt;
SendData (Copy(txt,Length(txt)-size+1,size));
end;

procedure TAdvancedPrinter.WriteCenter(txt, fill : string; size : integer);
begin
txt := Convert(txt);
while Length(txt) < size do txt := fill + txt + fill;
SendData (Copy(txt,(Length(txt)-size) div 2 + 1,size));
end;

procedure TAdvancedPrinter.WriteRepeat(txt : string; quant : integer);
var
s : string;
begin
s := ´´;
txt := Convert(txt);
while quant > 0 do begin
s := s + txt;
dec(quant);
end;
SendData (s);
end;


end.




Exemplo de implementação
procedure TForm1.Button2Click(Sender: TObject);
var
prn:TCharPrinter;
begin
if PrintDialog1.Execute then
Begin
prn := TCharPrinter.Create;
Prn.OpenDoc(´Titulo do documento´);
Prn.SendData(´LINHA UM E PULA PRA PRÓXIMA E VOLTA O CARRO DA IMPRESSORA´+#13+10);
Prn.SendData(´LINHA DOIS E PULA PRA PRÓXIMA E VOLTA O CARRO DA IMPRESSORA´+13+10);
Prn.SendData(12);
Prn.CloseDoc;
end;
end;

Caso não queira usar o PrintDialog o comando será enviado para a impressora padrão.

Um abraço galera!
Valeuuuuuuuuuuuuu!


Responder

Que tal ter acesso a um e-book gratuito que vai te ajudar muito nesse momento decisivo?

Ver ebook

Recomendado pra quem ainda não iniciou o estudos.

Eu quero
Ver ebook

Recomendado para quem está passando por dificuldades nessa etapa inicial

Eu quero

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar