You are not logged in.
Pages: 1
Hello
I am trying to write and draw text on the VCLCanvas.
This is a simple test to draw text in a high resolution environment (600 dpi as a typical laser printer)
This should draw the text and a box around it.
The text and boxes don't seem to align, unless i am doing something wrong.
Any Ideas
var MyX, MyY: Integer;
MyXLoc: Integer;
MyString: String;
lPdf : TPdfDocumentGDI;
lPage : TPdfPage;
begin
lPdf := TPdfDocumentGDI.Create;
try
lPage := lPDF.AddPage;
lPdf.ScreenLogPixels:=600;
MyY:=300;
for MyX := 1 to 40 do begin
MyXLoc:=MyX*120;
MyString:=IntToStr(MyX);
lPDF.VCLCanvas.TextOut(MyX*50, MyY, Mystring);
lPDF.VCLCanvas.Font.Size:= lPDF.VCLCanvas.Font.Size+4;
lPDF.VCLCanvas.Rectangle(MyXLoc, MyY, MyXLoc+lPDF.VCLCanvas.TextWidth(MyString), MyY+lPDF.VCLCanvas.TextHeight(MyString));
end;
lPdf.SaveToFile('c:\Syntest.pdf');
finally
lPdf.Free;
end;
Thank you all
Offline
I will try that. Thanks.
Offline
Sorry, thanks for the suggestion but that did not help. Did you try running this program and see the results?
Thank you
Fritz
Offline
Actually this works perfectly!
var MyX, MyY: Integer;
MyXLoc: Integer;
MyString: String;
lPdf : TPdfDocumentGDI;
lPage : TPdfPage;
begin
lPdf := TPdfDocumentGDI.Create;
try
lPdf.ScreenLogPixels:=600;
lPage := lPDF.AddPage;
lPdf.VCLCanvas.Brush.Style:=bsClear;
MyY:=300;
for MyX := 1 to 40 do begin
MyXLoc:=MyX*120;
MyString:=IntToStr(MyX);
lPDF.VCLCanvas.TextOut(MyXLoc, MyY, Mystring);
lPDF.VCLCanvas.Font.Size:= lPDF.VCLCanvas.Font.Size+4;
lPDF.VCLCanvas.Rectangle(MyXLoc, MyY, MyXLoc+lPDF.VCLCanvas.TextWidth(MyString), MyY+lPDF.VCLCanvas.TextHeight(MyString));
end;
lPdf.SaveToFile('c:\Syntest.pdf');
finally
lPdf.Free;
end;
end;
Offline
Pages: 1