Ajuda com Impressão linhas de um memo.
Tudo bem pessoal estou com um ploblema simples mas que não consigo resolver... Espero que possam me ajudar...
É o seguinte:
Tenho um memo que recebe dados de um csv, em cada linha há um número variado de "Campos" que vão de 1 até 21 que serão impressos como se fossem um cartão de respostas, ou cartão de loteria...
o memo apresenta os dados mais ou menos dessa forma...
1;2;5;18
7;9;11;14;21
5;9;10;12;17;21
5;9;16
O layout do cartão é assim
A B C
1 8 15 1 8 15 1 8 15
2 9 16 2 9 16 2 9 16
3 10 17 3 10 17 3 10 17
4 11 18 4 11 18 4 11 18
5 12 19 5 12 19 5 12 19
6 13 20 6 13 20 6 13 20
7 14 21 7 14 21 7 14 21
No momento consigo imprimir uma linha do memo a que corresponde a parte A do cartão de respostas apenas... a segunda linha també fica impressa na parte A.
O que gostaria é que cada linha linha fosse impressa na parte referente a ela, por exemplo a linha 1 na A a dois na B a três na C e quando ela fosse impressa passasse para um novo cartão...
Vou postar o código do que consegui até agora, se puderem me ajudar com ele ficarei muito grato...
É bem simples consiste em um form com um botão, um memo e um componente RvSystem da paleta Rave...
O código é esse:
Desde já meus agradecimentos... E muito obrigado pela atensão!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RpDefine, RpBase, RpSystem, StdCtrls,printers;
type
TForm1 = class(TForm)
Button1: TButton;
RvSystem1: TRvSystem;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure RvSystem1Print(Sender: TObject);
procedure RvSystem1BeforePrint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Procedure PrintString(
RVSystem:TRVSystem; // Objeto do RAVE
Row: Double; // Linha
Column:Double; // Coluna
TextToPrint:String; // Texto a ser impresso
NewFontName:String; // Fonte
NewFontSize:Integer; // Tamanho
NewFontColor:TColor // Cor
);
Begin
With RVSystem.BaseReport do Begin
GotoXY(Column,Row);
FontColor := NewFontColor;
FontSize := NewFontSize;
FontName := NewFontName;
Print(TextToPrint);
End;
End;
procedure TForm1.Button1Click(Sender: TObject);
begin
RVSystem1.SystemPreview.FormState := wsMaximized;
RVSystem1.DefaultDest := rdPreview; { poderia ser rdPrinter para impressora }
RVSystem1.SystemPrinter.Units := unMM; { Vamos trabalhar em Centimetoros }
RVSystem1.Execute;
end;
procedure TForm1.RvSystem1BeforePrint(Sender: TObject);
begin
with Sender as TBaseReport do
begin
SetPaperSize(0,8.7,17);
ClearTabs;
SetTab(NA ,pjLeft,0,0,BOXLINENONE,0);
SaveTabs(1);
end;
end;
procedure TForm1.RvSystem1Print(Sender: TObject);
var
i, num: integer;
//st: TStringList;
begin
Memo1.Lines.Delimiter := ';';
Memo1.Lines.DelimitedText := Memo1.Text;
for i := 0 to Memo1.Lines.Count - 1 do
begin
num := strtoint(Memo1.Lines[i]);
case num of
1 : begin
PrintString(RVSystem1,39,61,'_','Arial Bold',18,clBlack);
end;
2 : begin
PrintString(RVSystem1,39,55,'_','Arial Bold',18,clBlack);
end;
3 : begin
PrintString(RVSystem1,39,48.5,'_','Arial Bold',18,clBlack);
end;
4 : begin
PrintString(RVSystem1,39,42,'_','Arial Bold',18,clBlack);
end;
5 : begin
PrintString(RVSystem1,39,36,'_','Arial Bold',18,clBlack);
end;
6 : begin
PrintString(RVSystem1,39,29.5,'_','Arial Bold',18,clBlack);
end;
7 : begin
PrintString(RVSystem1,39,23,'_','Arial Bold',18,clBlack);
end;
8 : begin
PrintString(RVSystem1,39,17,'_','Arial Bold',18,clBlack);
end;
9 : begin
PrintString(RVSystem1,39,10.5,'_','Arial Bold',18,clBlack);
end;
10 : begin
PrintString(RVSystem1,39,4,'_','Arial Bold',18,clBlack);
end;
11 : begin
PrintString(RVSystem1,43,61,'_','Arial Bold',18,clBlack);
end;
12 : begin
PrintString(RVSystem1,43,55,'_','Arial Bold',18,clBlack);
end;
13 : begin
PrintString(RVSystem1,43,48.5,'_','Arial Bold',18,clBlack);
end;
14 : begin
PrintString(RVSystem1,43,42,'_','Arial Bold',18,clBlack);
end;
15 : begin
PrintString(RVSystem1,43,36,'_','Arial Bold',18,clBlack);
end;
16 : begin
PrintString(RVSystem1,43,29.5,'_','Arial Bold',18,clBlack);
end;
17 : begin
PrintString(RVSystem1,43,23,'_','Arial Bold',18,clBlack);
end;
18 : begin
PrintString(RVSystem1,43,17,'_','Arial Bold',18,clBlack);
end;
19 : begin
PrintString(RVSystem1,43,10.5,'_','Arial Bold',18,clBlack);
end;
20 : begin
PrintString(RVSystem1,43,4,'_','Arial Bold',18,clBlack);
end;
21 : begin
PrintString(RVSystem1,47.5,61,'_','Arial Bold',18,clBlack);
end;
22 : begin
PrintString(RVSystem1,47.5,55,'_','Arial Bold',18,clBlack);
end;
23 : begin
PrintString(RVSystem1,47.5,48.5,'_','Arial Bold',18,clBlack);
end;
24 : begin
PrintString(RVSystem1,47.5,42,'_','Arial Bold',18,clBlack);
end;
25 : begin
PrintString(RVSystem1,47.5,36,'_','Arial Bold',18,clBlack);
end;
26 : begin
PrintString(RVSystem1,47.5,29.5,'_','Arial Bold',18,clBlack);
end;
27 : begin
PrintString(RVSystem1,47.5,23,'_','Arial Bold',18,clBlack);
end;
28 : begin
PrintString(RVSystem1,47.5,17,'_','Arial Bold',18,clBlack);
end;
29 : begin
PrintString(RVSystem1,47.5,10.5,'_','Arial Bold',18,clBlack);
end;
30 : begin
PrintString(RVSystem1,47.5,4,'_','Arial Bold',18,clBlack);
end;
31 : begin
PrintString(RVSystem1,51.5,61,'_','Arial Bold',18,clBlack);
end;
32 : begin
PrintString(RVSystem1,51.5,55,'_','Arial Bold',18,clBlack);
end;
33 : begin
PrintString(RVSystem1,51.5,48.5,'_','Arial Bold',18,clBlack);
end;
34 : begin
PrintString(RVSystem1,51.5,42,'_','Arial Bold',18,clBlack);
end;
35 : begin
PrintString(RVSystem1,51.5,36,'_','Arial Bold',18,clBlack);
end;
36 : begin
PrintString(RVSystem1,51.5,29.5,'_','Arial Bold',18,clBlack);
end;
37 : begin
PrintString(RVSystem1,51.5,23,'_','Arial Bold',18,clBlack);
end;
38 : begin
PrintString(RVSystem1,51.5,17,'_','Arial Bold',18,clBlack);
end;
39 : begin
PrintString(RVSystem1,51.5,10.5,'_','Arial Bold',18,clBlack);
end;
40 : begin
PrintString(RVSystem1,51.5,4,'_','Arial Bold',18,clBlack);
end;
41 : begin
PrintString(RVSystem1,56,61,'_','Arial Bold',18,clBlack);
end;
42 : begin
PrintString(RVSystem1,56,55,'_','Arial Bold',18,clBlack);
end;
43 : begin
PrintString(RVSystem1,56,48.5,'_','Arial Bold',18,clBlack);
end;
end;
end;
end;
end.
Wilerson Shiroma
Curtidas 0