Gracias Casimiro.
No conocía esta opción.
Foto de la impresión con
Seattle.
Foto de la impresion con
Tokyo.
Y este es el código de impresión. Como podéis ver es una factura. (Siento que sea un poco largo...)
Código Delphi
[-]
function IH(N:integer):integer;
var
I:real;
begin
I:=Printer.Pagewidth/2892;
IH:=Round(i*N);
end;
function IV(N:integer):integer;
var
I:real;
begin I:=Printer.PageHeight/4125;
IV:=Round(i*N);
end;
procedure TEmpe.Imprimir;
VAR
XX, YY, Pagina, TotalPaginas:INTEGER;
SumaySigue : Double;
procedure NumeraPagina;
var
MyRect:TrectF;
begin
with Printer.Canvas
do begin
try
Font.Size := Form1.Pica.Font.Size;
Font.Family := Form1.Pica.Font.Family;
Font.Style := Form1.Pica.Font.Style;
Fill.Color := Form1.Pica.TextSettings.FontColor;
MyRect.Create(IH(125),IV(Printer.PageHeight-200),ih(Printer.PageWidth-150),iv(Printer.PageHeight-100));
FillText(MyRect, 'Página '+Pagina.ToString+' de '+TotalPaginas.ToString, false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Leading, TTextAlign.Center);
finally
end;
end;
end;
procedure Resumen;
var
MyRect:TrectF;
v1 : Integer;
S : String;
begin
with Printer.Canvas
do begin
try
v1 := 3000; while xx < DetallaEmpe.StringGrid1.RowCount do begin
if (DetallaEmpe.StringGrid1.Cells[2, xx] = '..................') and
(DetallaEmpe.StringGrid1.Cells[3, xx] <> '0,00') then begin
S := DetallaEmpe.StringGrid1.Cells[1, xx];
if S.IndexOf('I.V.A.') <> -1 then begin
S := S.Substring(S.Length-6,6) +' '+ S.Substring(0,7);
DetallaEmpe.StringGrid1.Cells[1, xx] := S;
end;
S := DetallaEmpe.StringGrid1.Cells[3, xx];
while S.Length < 10 do S := ' ' + S; S := DetallaEmpe.StringGrid1.Cells[1, xx] + '.......' + S;
Font.Size := Form1.Consolas.Font.Size;
Font.Family := Form1.Consolas.Font.Family;
Font.Style := Form1.Consolas.Font.Style;
Fill.Color := Form1.Consolas.TextSettings.FontColor;
MyRect.Create(IH(125),IV(v1),ih(Printer.PageWidth-150),iv(v1+100));
FillText(MyRect, S, false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Leading, TTextAlign.Center);
V1 := V1 + 75; end;
if (DetallaEmpe.StringGrid1.Cells[3, xx] = '') then begin
S := DetallaEmpe.StringGrid1.Cells[2, xx];
while S.Length < 10 do S := ' ' + S;
S := ' El ' +
DetallaEmpe.StringGrid1.Cells[0, xx] + ' por importe de ' + S;
Font.Size := Form1.Pica2.Font.Size;
Font.Family := Form1.Pica2.Font.Family;
Font.Style := Form1.Pica2.Font.Style;
Fill.Color := Form1.Pica2.TextSettings.FontColor;
MyRect.Create(IH(125),IV(v1),ih(Printer.PageWidth-550),iv(v1+75));
FillText(MyRect, S, false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Leading, TTextAlign.Center);
if DetallaEmpe.StringGrid1.Cells[3, xx+1] = ''
then V1 := V1 + 50 else V1 := V1 + 75; end;
Inc(xx);
end;
finally
end;
end;
end;
Procedure PonerLogo;
var
Rect : TRectF;
Rect2: TRectF;
Map : FMX.Graphics.TBitmap;
begin
with Printer.Canvas
do begin
Map := FMX.Graphics.TBitmap.Create();
Map.LoadFromFile('Icono144x144.bmp');
Rect := TRectF.Create(0,0,Map.Width,Map.Height);
Rect2 := TRectF.Create(350, 000, 765, 360);
try
DrawBitmap(Map, Rect, Rect2, 20, True);
finally
Map.Free;
end;
end;
end;
PROCEDURE CABECERA;
var
MyRect:TrectF;
p1,p2 : TPointF;
S, S2 : String;
Linea, CuentaLineas ,V1, V2, I: integer;
BEGIN
try Printer.BeginDoc;
if PortaNombr.Chars[PortaNombr.Length - 1] = '.' then PortaNombr := PortaNombr.Remove(PortaNombr.Length - 1,1);
pagina:=pagina+1;
with Printer.canvas
do begin
MyRect.Create(IH(125),IV(1050),ih(Printer.PageWidth-150),iv(3000));
DrawRect(MyRect, 0, 0, AllCorners, 100);
V1 := 1200;
for I := 1 to 18
do begin
p1 := TPointF.Create(IH(125),IV(V1));
p2 := TPointF.Create(ih(Printer.PageWidth-150),iv(V1));
DrawLine(p1,p2,100);
V1 := V1 + 100;
end;
p1 := TPointF.Create(IH(450),IV(1050));
p2 := TPointF.Create(ih(450),iv(3000));
DrawLine(p1,p2,100);
p1 := TPointF.Create(IH(1975),IV(1050));
p2 := TPointF.Create(ih(1975),iv(3000));
DrawLine(p1,p2,100);
p1 := TPointF.Create(IH(2350),IV(1050));
p2 := TPointF.Create(ih(2350),iv(3000));
DrawLine(p1,p2,100);
Font.Size := Form1.Doble.Font.Size;
Font.Family := Form1.Doble.Font.Family;
Font.Style := Form1.Doble.Font.Style;
Fill.Color := Form1.Doble.TextSettings.FontColor;
MyRect.Create(IH(125),IV(100),ih(Printer.PageWidth-150),iv(200));
FillText(MyRect, 'Trabajo en Curso', false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center);
if DetallaEmpe.StringGrid1.Cells[1, 0] <> ''
then begin
Font.Size := Form1.Pica.Font.Size;
Font.Family := Form1.Pica.Font.Family;
Font.Style := Form1.Pica.Font.Style;
Fill.Color := Form1.Pica.TextSettings.FontColor;
MyRect.Create(IH(125),IV(200),ih(Printer.PageWidth-150),iv(300));
FillText(MyRect, DetallaEmpe.StringGrid1.Cells[1, 0], false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center);
end;
Font.Size := Form1.Enfatica3.Font.Size;
Font.Family := Form1.Enfatica3.Font.Family;
Font.Style := Form1.Enfatica3.Font.Style;
Fill.Color := Form1.Enfatica3.TextSettings.FontColor;
MyRect.Create(IH(125),IV(1050),ih(450),iv(1200));
FillText(MyRect, 'Cantidad', false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center);
MyRect.Create(IH(450),IV(1050),ih(1975),iv(1200));
FillText(MyRect, 'C o n c e p t o', false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center);
MyRect.Create(IH(1975),IV(1050),ih(2350),iv(1200));
FillText(MyRect, 'Precio', false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center);
MyRect.Create(IH(2350),IV(1050),ih(Printer.PageWidth-150),iv(1200));
FillText(MyRect, 'Total', false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center);
if PortaNif <> '' then begin
PonerLogo;
Font.Size := Form1.Empresario.Font.Size;
Font.Family := Form1.Empresario.Font.Family;
Font.Style := Form1.Empresario.Font.Style;
Fill.Color := Form1.Empresario.TextSettings.FontColor;
MyRect.Create(IH(125),IV(325+40),ih(Printer.PageWidth div 2),iv(425+40));
FillText(MyRect, NomE , false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
Font.Size := Form1.Enfatica.Font.Size;
Font.Family := Form1.Enfatica.Font.Family;
Font.Style := Form1.Enfatica.Font.Style;
Fill.Color := Form1.Enfatica.TextSettings.FontColor;
MyRect.Create(IH(125),IV(450+40),ih(Printer.PageWidth-150),iv(525+40));
FillText(MyRect, 'N.I.F: '+ NifE +
' Teléf: ' + TelE.Substring(0,3)+' '+
TelE.Substring(3,2)+' '+
TelE.Substring(5,2)+' '+
TelE.Substring(7,2) , false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
Font.Size := Form1.Enfatica.Font.Size;
Font.Family := Form1.Enfatica.Font.Family;
Font.Style := Form1.Enfatica.Font.Style;
Fill.Color := Form1.Enfatica.TextSettings.FontColor;
MyRect.Create(IH(125),IV(525+40),ih(Printer.PageWidth div 2),iv(600+40));
FillText(MyRect, DirE, false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
MyRect.Create(IH(125),IV(600+40),ih(Printer.PageWidth div 2),iv(675+40));
FillText(MyRect,PobE.Substring(0,5), false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
MyRect.Create(IH(300),IV(600+40),ih(Printer.PageWidth div 2),iv(675+40));
FillText(MyRect,PobE.Substring(6,PobE.Length-6), false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
MyRect.Create(IH(125),IV(675+40),ih(Printer.PageWidth div 2),iv(750+40));
FillText(MyRect, ProvE, false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
end;
Font.Size := Form1.Titulo.Font.Size;
Font.Family := Form1.Titulo.Font.Family;
Font.Style := Form1.Titulo.Font.Style;
Fill.Color := Form1.Titulo.TextSettings.FontColor;
MyRect.Create(ih(Printer.PageWidth div 2 - 100),IV(325),ih(Printer.PageWidth -150),iv(475));
FillText(MyRect, 'Cliente' , false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center);
Font.Size := Form1.Cliente.Font.Size;
Font.Family := Form1.Cliente.Font.Family;
Font.Style := Form1.Cliente.Font.Style;
Fill.Color := Form1.Cliente.TextSettings.FontColor;
MyRect.Create(ih(Printer.PageWidth div 2)+150,IV(450),ih(Printer.PageWidth -150),iv(550));
FillText(MyRect, PortaNombr , false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
Font.Size := Form1.Enfatica2.Font.Size;
Font.Family := Form1.Enfatica2.Font.Family;
Font.Style := Form1.Enfatica2.Font.Style;
Fill.Color := Form1.Enfatica2.TextSettings.FontColor;
MyRect.Create(ih(Printer.PageWidth div 2)+150,IV(550),ih(Printer.PageWidth -150),iv(600));
if PortaNif <> '' then begin
FillText(MyRect, 'N.I.F: '+ PortaNif +
' Teléf: ' + PortaTelef.Substring(0,3)+' '+
PortaTelef.Substring(3,2)+' '+
PortaTelef.Substring(5,2)+' '+
PortaTelef.Substring(7,2) , false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
end
else begin
FillText(MyRect,
'Teléf: ' + PortaTelef.Substring(0,3)+' '+
PortaTelef.Substring(3,2)+' '+
PortaTelef.Substring(5,2)+' '+
PortaTelef.Substring(7,2) , false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
end;
S := PortaDirec;
V1 := 600;
V2 := 660;
Linea := 0;
while S <> ''
do begin
Inc(Linea);
if Linea <> 2
then begin
if S.IndexOf(#10) > -1 then S2 := S.Substring(0,S.IndexOf(#13))
else S2 := S;
if S2.Chars[S2.Length - 1] = '.' then S2 := S2.Remove(S2.Length - 1,1);
MyRect.Create(ih(Printer.PageWidth div 2)+150,IV(V1),ih(Printer.PageWidth -150),iv(V2));
FillText(MyRect, S2, False, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
end
else begin if S.IndexOf(#10) > -1 then S2 := S.Substring(0,S.IndexOf(#13))
else S2 := S;
if S2.Chars[S2.Length - 1] = '.' then S2 := S2.Remove(S2.Length - 1,1);
MyRect.Create(ih(Printer.PageWidth div 2)+150,IV(V1),ih(Printer.PageWidth -150),iv(V2));
FillText(MyRect, S2.Substring(0,5), False, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
MyRect.Create(ih(Printer.PageWidth div 2)+300,IV(V1),ih(Printer.PageWidth -150),iv(V2));
FillText(MyRect, S2.Substring(6,S2.Length-6), False, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
end;
V1 := V2;
V2 := V2 + 60;
if S.IndexOf(#10) > -1 then S := S.Remove(0,S.IndexOf(#10)+1)
else S := '';
end;
Font.Size := Form1.PicaNegra.Font.Size;
Font.Family := Form1.PicaNegra.Font.Family;
Font.Style := Form1.PicaNegra.Font.Style;
Fill.Color := Form1.PicaNegra.TextSettings.FontColor;
MyRect.Create(IH(125),IV(950),ih(Printer.PageWidth-150),iv(1010));
FillText(MyRect, 'Trabajo en Curso Núm: TE'+PortaRef+' Fecha: '+
PortaFInic, false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center);
Font.Size := Form1.PicaNegra.Font.Size;
Font.Family := Form1.PicaNegra.Font.Family;
Font.Style := Form1.PicaNegra.Font.Style;
Fill.Color := Form1.PicaNegra.TextSettings.FontColor;
v1 := 1200;
CuentaLineas := 0;
while (CuentaLineas < 18) and (DetallaEmpe.StringGrid1.Cells[1, xx] <> 'Total Materiales y Mano de Obra')
do begin
MyRect.Create(IH(125),IV(v1),ih(450),iv(v1+100));
FillText(MyRect, DetallaEmpe.StringGrid1.Cells[0, xx], false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Leading, TTextAlign.Center);
MyRect.Create(IH(450),IV(v1),ih(1975),iv(v1+100));
FillText(MyRect, DetallaEmpe.StringGrid1.Cells[1, xx], false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Trailing, TTextAlign.Center);
MyRect.Create(IH(1975),IV(v1),ih(2350),iv(v1+100));
FillText(MyRect, DetallaEmpe.StringGrid1.Cells[2, xx], false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Leading, TTextAlign.Center);
MyRect.Create(IH(2350),IV(v1),ih(Printer.PageWidth-150),iv(v1+100));
FillText(MyRect, DetallaEmpe.StringGrid1.Cells[3, xx], false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Leading, TTextAlign.Center);
v1 := v1 + 100;
S := DetallaEmpe.StringGrid1.Cells[3, xx];
while S.IndexOf('.') <> -1
do S := S.Remove(S.IndexOf('.'), 1);
SumaySigue := SumaySigue + S.ToDouble;
Inc(xx);
Inc(CuentaLineas);
end;
if (Pagina = TotalPaginas) then Resumen
else begin MyRect.Create(IH(125),IV(3300),ih(Printer.PageWidth-150),iv(3400));
FillText(MyRect, 'Suma y Sigue................'+Format( '%n', [SumaySigue] ), false, 100,[TFillTextFlag.RightToLeft], TTextAlign.Leading, TTextAlign.Center);
end;
NumeraPagina;
end;
Printer.EndDoc;
except
Printer.Abort;
raise;
end;
END;
BEGIN
xx := 1;
Pagina := 0;
SumaySigue := 0.00;
yy := 1; while (DetallaEmpe.StringGrid1.Cells[1, yy+1] <> 'Total Materiales y Mano de Obra')
do Inc(yy);
TotalPaginas := yy div 18;
if yy mod 18 > 0
then TotalPaginas := TotalPaginas + 1;
Printer.ActivePrinter.SelectDPI(600,600);
repeat
Cabecera;
until Pagina = TotalPaginas;
END;