#1 2017-12-02 11:55:15

katcharowski
Member
Registered: 2017-12-02
Posts: 2

VCLCanvas.TextRect or VCLCanvas.TextOut

I need to print a text aligned from right to left using TPdfDocumentGDI and VCLcanvas. What is missing in this code for it to work?

procedure TForm2.Button3Click(Sender: TObject);
var  lPdf         : TPdfDocumentGDI;
      lPage       : TPdfPage;
      DrawRect : TRect;
begin
      lPdf := TPdfDocumentGDI.Create;

      lPdf.DefaultPaperSize   := psA4;
      lPdf.ScreenLogPixels    := 50;

      lPdf.Info.Author           := 'SINTEG Sistemas de Informação';
      lPdf.Info.CreationDate  := Now;
      lPdf.Info.Creator          := 'Sinteg Web-mobile';
      lpdf.Info.Title               := 'Relatório de Contas a Receber';
      lpdf.Info.Subject          := 'Ordenado por Cliente';

      lPDF.VCLCanvas.Font.Size  := 7;
      lPDF.VCLCanvas.Font.Name  := 'Arial';
      lPDF.VCLCanvas.Font.color := clred;
      lPDF.VCLCanvas.Font.Style := [fsbold,fsitalic];

      lpdf.VCLCanvas.TextRect(DrawRect, 130, 21, 'printed from left to right');
      lpdf.VCLCanvas.TextRect(DrawRect, 130, 31, 'printed from right to left');
end;

the result should be this:

------------------------------------------------------ col 130 --------------------------

                                                                       printed from left to right
                                     printed from right to left

Offline

#2 2017-12-02 12:21:05

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

Re: VCLCanvas.TextRect or VCLCanvas.TextOut

Why not just use the text alignment options of the VCL TCanvas?

Offline

#3 2017-12-04 21:50:39

katcharowski
Member
Registered: 2017-12-02
Posts: 2

Re: VCLCanvas.TextRect or VCLCanvas.TextOut

please tell me how the syntax of this command is, since I tried anyway to find something that solved my problem, but I did not find it.
I searched everywhere and found nothing.
I reviewed each VCL canvas procedure, but I did not get anything.

Offline

#4 2017-12-05 09:03:12

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

Re: VCLCanvas.TextRect or VCLCanvas.TextOut

Did you try to use the SetTextAlign() API function?

Also consider using the mORMotReport.pas unit, if you want simple text process.

Offline

Board footer

Powered by FluxBB