Fórum Maiores informações sobre Mini Impressoras #343313
16/07/2007
0
Pesquisei, mas não encontrei algo parecido.
Então vamos a pergunta.
Recentemente desenvolvo aplicativos comerciais utilizando a linha da Bematech. Acontece que na região estou encontrando muitas impressoras não fiscais e fiscais de outras marcas tipo Epson, Daruma, etc.
Acontece que a Daruma, disponibiliza opções para as impressoras dela, como a bematech, Mas o gargalo é a Epson.
Alguém já desenvolveu algum programa que utiliza as mini impressoras da Epson?
Pois o problema é como imprimir dados nela, pois a bema e a daru, já disponibilizam drives, bibliotecas, fontes e tudo mais para vc utilizar as mini impressoras dela, e a Epson, como é que fica.... falta material... já pesquisei no site da epson e nada.
Se alguem poder compartilhar ideías do funcionamento dela, a comunidade agradece.
Grato a todos.
Valnei
Objetivacreator
Curtir tópico
+ 0Posts
17/07/2007
Edilcimar
Gostei + 0
18/07/2007
Sergiokm
Gostei + 0
18/07/2007
Vitor Alcantara
Eu utilizo nas impressões de mini impressoras uma Unit Chamada CharPrinter que me da a flexibilidade de impressão em rede e também envia os dados para a fila de impressão da impressora assim deixando a aplicação livre sem ter que esperar que a impressora imprima pra destravar a aplicação. ( o que ocorre utilizando TextFile).
Olha o código ai da unit:
//---------------------------------------------------------------
// 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.
pra utilizar faz assim:
procedure TForm1.BitBtn1Click(Sender: TObject); var prn:TCharPrinter; ln : string = #13 + 10; begin prn := TCharPrinter.Create; Prn.OpenDoc(´Titulo do documento´); Prn.SendData(´LINHA UM E PULA PRA PRÓXIMA E VOLTA O CARRO DA IMPRESSORA´+ln); Prn.SendData(´LINHA DOIS E PULA PRA PRÓXIMA E VOLTA O CARRO DA IMPRESSORA´+ln); Prn.CloseDoc; end;
O caractere #13 serve para pular para a póxima linha
O caractere 10 serve para voltar o carro da impressora
Ps Lembrar de declarar a unit CharPrinter no uses do teu form.
Você pode utilizar uma impressora Genérico Somente Texto para fazer a impressão.
Gostei + 0
19/07/2007
Sergiokm
Gostei + 0
19/07/2007
Vitor Alcantara
Só complementando a minha idéia você quando for chamar a rotina de impressão utilize um PrintDialog para que você possa escolher a impressora que vai imprimir se não ela irá enviar para a impressora padrão.
procedure TForm1.BitBtn1Click(Sender: TObject); var prn:TCharPrinter; ln : string = #13 + 10; 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´+ln); Prn.SendData(´LINHA DOIS E PULA PRA PRÓXIMA E VOLTA O CARRO DA IMPRESSORA´+ln); Prn.CloseDoc; end; end;
Gostei + 0
23/07/2007
Objetivacreator
Venho aqui agradecer ao amigo vitoraraujo, pela disponibilidade e pela compreensão deixada por ela.
Ultimamente o crescimento do uso das mini impressoras tem proporcionado um ganho substancial ao desenvolvedores em delphi.
Há muito o que debater ainda, mas a união faz a força. Há mercado para todos, o crescimento de computadores esta melhor que antes. Segundo o siste olhardigital.com, até 2011 o crescimento será em torno de 1 bil nas vendas de computadores. Aquelas pequenas empresas, pequenas lojas de comércio em geral, vão colocar micros e com certeza as mini impressoras, com isto o aumento no desenvolvimento de novas aplicações comerciais.
Vamos continuar nesta aventura.
Desde já agradeço mais uma vez a todos que só olharam o comentário ou até mesmo tentou ajudar, como os que se dispuseram a ajudar com toda a comunidade.
Um forte abraço a todos e até mais...
Gostei + 0
23/07/2007
Fabiano Góes
Estou desenvolvendo um sistema para um comercio onde vai precisar utilizar uma impressora fiscal, como a minha area de desenvolvimento era outra será a primeira vez que vou trabalhar com essas impressoras.
tenho uma dúvida:
para imprimir em impressoras fiscais posso fazer uma impressao direta e a propria impressora se encarrega da parte fiscal ou existe algumas normas para isso ???
Gostei + 0
23/07/2007
Edilcimar
Gostei + 0
24/07/2007
Vitor Alcantara
Mais existe um componente (muito bom por sinal) chamado ACBrECF que faz parte do projeto ACBr que está disponivel nesse endereço
[url]http://acbr.sourceforge.net[/url], vale a pena dar uma olhada pois já vem com um exemplo de cada componente do projeto.
Gostei + 0
29/07/2007
Vitor Alcantara
ex:
procedure TForm1.Button1Click(Sender: TObject); var prn : TAdvancedPrinter; begin if PrintDialog1.Execute then begin prn := TAdvancedPrinter.Create; prn.OpenDoc(´NOrmal´);//Imprime fonte normal prn.FontSize := pfs20cpi;//Troca fonte para tamanho 20 prn.WriteRight(´Normal´,´ ´,40);//Alinhado a direita sendo que a bobina tem 40 caracteres prn.Write(´Fonte 20cpi´); prn.CRLF;//Volta carro e pula linha prn.FontSize := pfs10cpi;//Troca fonte para tamanho 10 prn.Write(´Fonte 10cpi´); prn.CRLF; prn.FontSize := pfs5cpi;//Troca fonte para tamnho 5 prn.TextStyle := [psBold];//Coloca em negrito prn.Write(´Fonte 5cpi em negbrito´); prn.CRLF; prn.WriteRepeat(´#´,40);//Escreve prn.FF;//Salta página prn.CloseDoc; end; end;
Gostei + 0
01/08/2007
Dominioararangua
se imprimir, será uma mão na roda...
Rodrigo
Gostei + 0
01/08/2007
Vitor Alcantara
Mais se a for uma porta paralela e devera funcionar.
Gostei + 0
14/01/2008
Ronaldordj
Att, Ronaldo
Gostei + 0
14/01/2008
Vitor Alcantara
Amigo você está querendo imprimir uma imagem direto pra impressora? Se for isso acho que talvez seria mais fácil você obter esse resultado utilizando a unit tPrinter.
Da uma olhada nesse tópico talvez ache o que está procurando.
https://www.devmedia.com.br/articles/viewcomp.asp?comp=2677&hl=
Sinto não poder ajudar mais pois pouco conheço sobre o objeto Printer.
Gostei + 0
14/01/2008
Sergiokm
usando canvas:
var F: TextFile;
...
AssignPrn(F); // Canvas
Rewrite(F);
Printer.Canvas.Font.Name:=´FontB11´;
Writeln(F,´+´+StringOfChar(´-´,40)+´+´);
Printer.Canvas.Font.Name:=´FontB12´; // ativa dupla altura
WriteLn(F,´CARTORIO DO 1º OFICIO DE NOTAS´);
Printer.Canvas.Font.Name:=´FontB11´;
WriteLn(F,´Telefone´);
CloseFile(F);
...
Usando impressão direta na LPT1:
Comandos ESC/POS
...
AssignFile(F,´LPT1´); // Direto Lpt1
Rewrite(F);
Write(F,chr(27),chr(116),chr(3));
Writeln(F,#27331,chr(218)+StringOfChar(´-´,40)+chr(191));
WriteLn(F,273317,´CARTORIO DO 1º OFICIO DE NOTAS´); // ativa dupla altura
WriteLn(F,27331,´Telefone´);
CloseFile(F);
...
Tanto o nome das fontes como os códigos ASCII da tabela ESC/POS constam no manual da TM-U295. A tabela completa de codigo ESC/POS você acha pela net, não as tenho mais.
Usei estes comandos e desisti de usar esta impressora, não consegui fazer impressões confiáveis com ela. Tudo vai indo bem, e de repente, ela imprime fora de posição!
Se alguém souber uma maneira eficiente de usar esta impressora, também gostaria de saber.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)