#1 2020-03-25 18:52:19

jbannon
Member
Registered: 2020-03-25
Posts: 3

TextRect w/ TPdfDocumentGDI

Although Delphi (10.3.2) acknowledges the procedure TextRect exists, it won't compile. It stops on

   lpdf.VCLCanvas.TextRect(R, 'Now is the time for all good men', [tfCenter]);

with the error message:  [dcc32 Error] Unit1.pas(66): E2250 There is no overloaded version of 'TextRect' that can be called with these arguments

I've tried it with different values for TextFormat with the same result. My rect is declared as TPDFRect. My version of SynPDF.pas is dated 3/13/2020.

What's the problem?

Offline

#2 2020-03-26 00:30:11

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

Re: TextRect w/ TPdfDocumentGDI

If you use the VCLCanvas, you should use a VCL TRect, not a TPDFRect.

You are mixing/confusing the PDF Canvas and the VCL Canvas.

Offline

#3 2020-03-26 14:25:31

jbannon
Member
Registered: 2020-03-25
Posts: 3

Re: TextRect w/ TPdfDocumentGDI

Thanks. But using TRect produces the same compile error: [dcc32 Error] Unit1.pas(67): E2250 There is no overloaded version of 'TextRect' that can be called with these arguments

Offline

#4 2020-03-26 14:51:51

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: TextRect w/ TPdfDocumentGDI

The problem is in the string, not in TRect.

See the declaration of this method in the vcl.Graphics unit (which has no relation to SynPdf)

procedure TCanvas.TextRect(var Rect: TRect; var Text: string; TextFormat: TTextFormat = []);

The "Text" param is "var". So you can't pass a constant.

Try

var
 MyText : String;
begin
  MyText :=  'Now is the time for all good men';
  lpdf.VCLCanvas.TextRect(R,MyText, [tfCenter]);
  ...
end;

Offline

#5 2020-03-26 16:25:14

jbannon
Member
Registered: 2020-03-25
Posts: 3

Re: TextRect w/ TPdfDocumentGDI

Thanks. That was it.

Offline

Board footer

Powered by FluxBB