hidrau
asked on
Working with printer
hello Guys, I am trying to work with printer but I am having some problens with it. As You can see I have a line with QTd
Codigo and locação. I would like to print them aligned like this example:
Qtd Cod Locação
5631 748547 415a5177B1
56 784 748596
123 74 744aB
With Printer do
Begin
Orientation := poLandscape;
BeginDoc;
Canvas.Pen.Width := 2;
Canvas.Font.Name := 'Times New Roman';
Canvas.Font.Size := 12;
Tam := Canvas.TextWidth('a');
Col := 10;
Canvas.TextOut(10,250 ,' Qtd Código Locação');
Canvas.TextOut(Col,290, Qtd);
Col := Col + (Tam * 16);
Canvas.TextOut(Col,290, Cod);
Col := Col + (Tam * 20);
Canvas.TextOut(Col,290, Aloc);
EndDoc
Codigo and locação. I would like to print them aligned like this example:
Qtd Cod Locação
5631 748547 415a5177B1
56 784 748596
123 74 744aB
With Printer do
Begin
Orientation := poLandscape;
BeginDoc;
Canvas.Pen.Width := 2;
Canvas.Font.Name := 'Times New Roman';
Canvas.Font.Size := 12;
Tam := Canvas.TextWidth('a');
Col := 10;
Canvas.TextOut(10,250 ,' Qtd Código Locação');
Canvas.TextOut(Col,290, Qtd);
Col := Col + (Tam * 16);
Canvas.TextOut(Col,290, Cod);
Col := Col + (Tam * 20);
Canvas.TextOut(Col,290, Aloc);
EndDoc
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You need to subtract the Textwidth of your output
i.e.
say
Column 1 starts at 0 and goes to 100
Column 2 starts at 101 and goes to 200
Column 3 starts at 201 and goes to 300
Use TextRect
with Canvas do
begin
lRect:=Rect(0,20,100,50) -- assuming a 30 pixel row height
TextRect(lRect,lRect.Right -TextWidth (Qtd),Qtd) ;
lRect:=Rect(101,20,200,50) -- assuming a 30 pixel row height
TextRect(lRect,lRect.Right -TextWidth (Qtd),Cod) ;
lRect:=Rect(201,20,300,50) -- assuming a 30 pixel row height
TextRect(lRect,lRect.Right -TextWidth (Qtd),Aloc );
end;
you obviously need to increment the top and bottom of the rects for the rows
regards
i.e.
say
Column 1 starts at 0 and goes to 100
Column 2 starts at 101 and goes to 200
Column 3 starts at 201 and goes to 300
Use TextRect
with Canvas do
begin
lRect:=Rect(0,20,100,50) -- assuming a 30 pixel row height
TextRect(lRect,lRect.Right
lRect:=Rect(101,20,200,50)
TextRect(lRect,lRect.Right
lRect:=Rect(201,20,300,50)
TextRect(lRect,lRect.Right
end;
you obviously need to increment the top and bottom of the rects for the rows
regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hidrau, with Courier both strings " 38" and "00038", because it is fixed width. Just add spaces to the strings.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys for you help.
I am gonna open another question with printing image with canvas
Alex
I am gonna open another question with printing image with canvas
Alex
ASKER
And quickreport doesn't work correctly with a printer drive for a kind of printer I am working.
I am gonna try with courier, but do you know how can I align?