#1 2020-05-25 16:27:46

Christope
Member
Registered: 2020-05-23
Posts: 4

CreateHyperLink function

Working with Delphi 10.
I started to create a PDF document, it works ok so far.
Then I tried to create a hyperlink over part of the text, by calling CreateHyperling with the right parameters. When I open the pdf doc, the cursor changes as expected when passing over the text, but nothing happens when I click. Did I miss something?
Thanks

Offline

#2 2020-05-26 07:15:30

asdjklf
Member
Registered: 2018-07-18
Posts: 9

Re: CreateHyperLink function

There is a bug and it was mentioned multiple times here, but somehow it is still not fixed. I am not sure why. Maybe the authors refuse to fix this? They never answered as far as I know.

Offline

#3 2020-05-26 11:39:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,504
Website

Re: CreateHyperLink function

Pull request maybe?

Online

#4 2020-05-26 12:15:46

asdjklf
Member
Registered: 2018-07-18
Posts: 9

Re: CreateHyperLink function

Well, my last pull request was not merged for over a month without a comment: https://github.com/synopse/mORMot/pull/296
Why would I provide another?

Offline

#5 2022-12-01 20:28:48

andyhill
Member
Registered: 2014-08-10
Posts: 4

Re: CreateHyperLink function

I am using Delphi Alexander and have SynPDF working but I need to create a PDF document with a HyperLink (URL) please advise - thanks

Offline

#6 2022-12-02 08:15:54

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,504
Website

Re: CreateHyperLink function

You have TPdfDocument.CreateHyperLink().

Online

#7 2022-12-03 04:06:09

andyhill
Member
Registered: 2014-08-10
Posts: 4

Re: CreateHyperLink function

procedure TForm1.Button1Click(Sender: TObject);
var
lPdf   : TPdfDocument;
lPage  : TPdfPage;
begin
  lPdf := TPdfDocument.Create;
  try
    lPdf.Info.Author        := 'Tester';
    lPdf.Info.CreationDate  := Now;
    lPdf.Info.Creator       := 'Tester';
    lPdf.DefaultPaperSize   := psA4;
    lPage := lPDF.AddPage;
    lPdf.Canvas.SetFont('Helvetica',10.0,[]);
    lPdf.Canvas.SetLeading(lPDF.Canvas.Page.FontSize);
    lPdf.Canvas.SetLineWidth(0.1);

    lPdf.Canvas.BeginText;
    lPdf.Canvas.TextOut( 300, 700,  'This is some text.');
    lPdf.Canvas.EndText;
    lPdf.CreateHyperLink(); // NO SUCH FUNCTION - What Have I missed ?
    lPdf.SaveToFile('....\test.pdf');
  finally
    lPdf.Free;
  end;
end;

Offline

#8 2022-12-03 04:10:29

andyhill
Member
Registered: 2014-08-10
Posts: 4

Re: CreateHyperLink function

Version 1.18.613

Offline

#9 2022-12-03 04:40:21

andyhill
Member
Registered: 2014-08-10
Posts: 4

Re: CreateHyperLink function

OK, found a later version 1.18.6439 - CreateHyperLink Exists.

Is there an easy way to calculate the text height for TPdfRect ?

procedure TForm1.Button1Click(Sender: TObject);
var
lPdf   : TPdfDocument;
lPage  : TPdfPage;
r      : TPdfRect;
begin
  r.Left:= 300;
  r.Top:=  700;
  r.Right:= 500;
  r.Bottom:= 750;
  lPdf := TPdfDocument.Create;
  try
    lPdf.Info.Author        := 'Tester';
    lPdf.Info.CreationDate  := Now;
    lPdf.Info.Creator       := 'Tester';
    lPdf.DefaultPaperSize   := psA4;
    lPage := lPDF.AddPage;
    lPdf.Canvas.SetFont('Helvetica',10.0,[]);
    lPdf.Canvas.SetLeading(lPDF.Canvas.Page.FontSize);
    lPdf.Canvas.SetLineWidth(0.1);

    lPdf.Canvas.BeginText;
    lPdf.Canvas.TextOut( 300, 700,  'Axfite Pty Ltd.');
//    lPdf.Canvas.EndText;
    lPdf.CreateHyperLink(r, 'https://axfite.com.au', abSolid, 1);
    lPdf.Canvas.EndText;

    lPdf.SaveToFile('....\test.pdf');
  finally
    lPdf.Free;
  end;
end;

Also, why did rect border line not paint ?

Last edited by andyhill (2022-12-03 07:28:33)

Offline

Board footer

Powered by FluxBB