#1 2011-05-03 12:16:29

photofritz
Member
Registered: 2011-04-16
Posts: 14

Am I missing something?

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

#2 2011-05-03 13:37:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Am I missing something?

Did you try to set  lPdf.ScreenLogPixels:=600; before AddPage method call?

In all cases, resolution of pdf is quasi infinite.

Offline

#3 2011-05-03 14:02:27

photofritz
Member
Registered: 2011-04-16
Posts: 14

Re: Am I missing something?

I will try that. Thanks.

Offline

#4 2011-05-03 14:04:02

photofritz
Member
Registered: 2011-04-16
Posts: 14

Re: Am I missing something?

Sorry, thanks for the suggestion but that did not help. Did you try running this program and see the results?

Thank you
Fritz

Offline

#5 2011-05-03 15:16:41

photofritz
Member
Registered: 2011-04-16
Posts: 14

Re: Am I missing something?

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

Board footer

Powered by FluxBB