Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > FireMonkey
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 01-07-2017
el-mono el-mono is offline
Miembro
 
Registrado: abr 2008
Ubicación: Lules
Posts: 176
Poder: 16
el-mono Va por buen camino
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;
Responder Con Cita
  #2  
Antiguo 05-10-2017
jhonalone jhonalone is offline
Miembro
 
Registrado: sep 2007
Ubicación: Madrid
Posts: 545
Poder: 17
jhonalone Va por buen camino
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.
__________________
"Pedid y se os dará; buscad y hallaréis ..." (Lc 11,9-10)
"...si no tengo caridad, nada soy..." (1 Cor 13,1-13)
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Error al imprimir archivo de texto en impresora en red vicvil Impresión 2 17-08-2013 00:01:25
En Que impresora imprimir? Waldo Impresión 2 05-10-2012 22:24:42
imprimir en impresora de red ethangio Varios 7 29-02-2012 03:49:01
Imprimir texto haciendo uso del API de Windows dec Trucos 0 30-06-2006 23:55:21
Imprimir directamente en la impresora? danytorres Impresión 1 12-01-2004 22:23:07


La franja horaria es GMT +2. Ahora son las 19:40:31.


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
Copyright 1996-2007 Club Delphi