Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   FireMonkey (https://www.clubdelphi.com/foros/forumdisplay.php?f=50)
-   -   Imprimir texto sobre impresora en Windows (https://www.clubdelphi.com/foros/showthread.php?t=92017)

el-mono 01-07-2017 06:05:11

Imprimir texto sobre impresora en Windows
 
Buenas a todos, necesito imprimir texto sobre impresora en Windows utilizando Firemonkey. Utilizo Delphi 10.1 Berlin.

Con el siguiente código logre imprimir, pero el texto sale muy pequeño y no logro manipularlo para agrandar el texto.

Código Delphi [-]
var
  MyRect: TRectF;
begin
// Image1.Bitmap.Clear($FFFFFF);
  // sets the rectangle where the text will be displayed
  MyRect := TRectF.Create(0, 0, 400, 570);
  // fills and draws the text in the specified rectangle area of the canvas
 
  Printer.BeginDoc;
  Printer.Canvas.Font.Style := [];
  Printer.Canvas.Font.Size := 12;
  Printer.Canvas.FillText(MyRect, 'Texto a Imprimir', false, 1,[], TTextAlign.Center, TTextAlign.Center);
  Printer.EndDoc;

jhonalone 05-10-2017 21:08:29

Hola el-mono.

Yo lo hago de la siguiente manera.

1.- Coloco una Label invisible en la forma o (mejor) visible en una forma general, que yo llamo Comunes.

2.- Utilizo las propiedades de esta label para pasarlas al canvas de la impresora.

La cuestión quedaría así:

Código Delphi [-]

uses
 Comunes; // Form1

procedure ImpriMemo(TS : TStrings); // Esto es para imprimir las líneas de un TMemo
var
  i, V1: Integer;
  Linea: Integer;
  MyRect : TRectF;
  S : String;
begin
  with Printer.Canvas
 do begin
     try 
        Printer.BeginDoc;
        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(0),IV(150),ih(Printer.PageWidth-150),iv(3850));

        DrawRect(MyRect, 0, 0, AllCorners, 100); // Rectángulo delimitador


        V1 := 155;
        for i := 0 to TS.Count - 1 do
        begin
          S := TS[i];
          MyRect.Create(IH(0),IV(v1),ih(Printer.PageWidth-150),iv(v1+75));
          FillText(MyRect, S, False, 100,[TFillTextFlag.RightToLeft], TTextAlign.Leading, TTextAlign.Center);
          v1 := v1 + 75;
        end;
        Printer.EndDoc;
        except
        Printer.Abort;
        raise;
        end; // de try
     end;// de with
end;

Tienes que incluír las propiedades del texto en el canvas de Prienter. Si no lo cambia la letra.

Saludos.


La franja horaria es GMT +2. Ahora son las 00:10:23.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi