You are not logged in.
Here's an example code:
procedure TForm1.Button1Click(Sender: TObject);
var
Doc: TPdfDocumentGDI;
Rect: TRect;
begin
Doc:=TPdfDocumentGDI.Create;
Doc.AddPage;
Doc.VCLCanvas.Brush.Style:=bsClear;
Doc.VCLCanvas.Font.Name := 'Arial';
Doc.VCLCanvas.Font.Size := 1;
Doc.VCLCanvas.Font.PixelsPerInch := 75;
Rect := TRect.Create(2,0,594,16);
Doc.VCLCanvas.TextRect(Rect, 2, 0, '...');
Rect.Top := 16;
Rect.Bottom := 31;
Doc.VCLCanvas.Font.Size := 9;
Doc.VCLCanvas.TextRect(Rect, 2, 19, 'Abc');
Doc.SaveToFile('test.pdf');
end;
It creates a simple pdf, draws '...' to the canvas at font size 1, then draws 'Abc' at font size 9 under it and finally saves it to a file.
The problem is that 'Abc' is sort of stretched across, completely messing the text:
Any idea what is causing this or is it a bug in the PDF engine?
Offline
Thanks for tip! Tested without PixelsPerInc and still some problems. Font size 9 prints out as it should be now, but at least font sizes 8, 10 and 11 (possibly more) still has the same problem.
procedure TForm1.Button3Click(Sender: TObject);
var
Doc: TPdfDocumentGDI;
Rect: TRect;
begin
Doc:=TPdfDocumentGDI.Create;
Doc.AddPage;
Doc.VCLCanvas.Brush.Style:=bsClear;
Doc.VCLCanvas.Font.Name := 'Arial';
Doc.VCLCanvas.Font.Size := 1;
Rect := TRect.Create(195,28,594,41);
Doc.VCLCanvas.TextRect(Rect, 218, 28, '...');
Rect.Top := 45;
Rect.Bottom := 59;
Doc.VCLCanvas.Font.Size := 10; // this works with 9, but breaks with 8, 10, 11
Doc.VCLCanvas.TextRect(Rect, 218, 45, 'Test');
Doc.SaveToFile('test.pdf');
end;
Offline
Meaning the ScreenLogPixels-property? Tried messing with it but seems it doesn't affect this. Interesting thing is that if I draw text at font 9, every textrect after it is drawn properly.
Doc:=TPdfDocumentGDI.Create;
Doc.ScreenLogPixels := 72;
Doc.AddPage;
Doc.VCLCanvas.Brush.Style:=bsClear;
Doc.VCLCanvas.Font.Name := 'Arial';
Doc.VCLCanvas.Font.Size := 1;
Rect := TRect.Create(195,28,594,41);
Doc.VCLCanvas.TextRect(Rect, 218, 28, '...');
Rect.Top := 45;
Rect.Bottom := 59;
Doc.VCLCanvas.Font.Size := 8;
Doc.VCLCanvas.TextRect(Rect, 218, 45, 'Test');
Rect.Top := 60;
Rect.Bottom := 76;
Doc.VCLCanvas.Font.Size := 9;
Doc.VCLCanvas.TextRect(Rect, 218, 60, 'Test');
Rect.Top := 77;
Rect.Bottom := 92;
Doc.VCLCanvas.Font.Size := 8;
Doc.VCLCanvas.TextRect(Rect, 218, 77, 'Test');
Doc.SaveToFile('test.pdf');
Running this gives pdf looking bit like this, in 200% zoom in pdf viewer:
Topmost line is the three dots drawn in font size 1, which triggers weird font for subsequent textrects. Second line is the font size 8 Test-text, which is in the weird font. Third line is font size 9 Test-text, which is drawn as expected and after this any further textrects are in the expected font, such as the fourth line size 8 Test-text.
Offline