#1 2019-01-25 21:24:57

jeanmilost
Member
Registered: 2016-01-21
Posts: 35

Bug in the CreateHyperLink() function?

I noticed that the links generated by the CreateHyperLink() function seems wrong. Using this function I get the following result in my PDF File:

...
6 0 obj
<</Type/Annot/Subtype/Link/F 4/BS<</W 0>>/Rect[10 10 310 60]>>
endobj
7 0 obj
<</S/URI/URI(http://www.google.com/)>>
endobj
...

However this doesn't work, and nothing happen while I click on the active link rect.

Now if I modify the CreateHyperLink() function this way:

function TPdfDocument.CreateHyperLink(const ARect: TPdfRect; const url : RawUTF8;
  BorderStyle: TPdfAnnotationBorder; BorderWidth: integer): TPdfDictionary;
var aURIObj: TPdfDictionary;
begin
  result := CreateAnnotation(asLink,ARect,BorderStyle,BorderWidth);
  aURIObj := TPdfDictionary.Create(FXref);
  aURIObj.FSaveAtTheEnd := true;
  aURIObj.AddItem('Type', 'Action');
  aURIObj.AddItem('S', 'URI');
  aURIObj.AddItemTextUTF8('URI', url);
  result.AddItem('A', aURIObj);
end;

I get the following result:

...
6 0 obj
<</Type/Annot/Subtype/Link/F 4/BS<</W 0>>/Rect[10 10 310 60]/A<</Type/Action/S/URI/URI(http://www.google.com/)>>>>
endobj
...

Which is working as expected: when I click on the link active rect, the Google page is opened.

I have several times asked questions about this function, and how to insert a hyperlink into my PDF page. No answer has ever been given. Am I the only developer who can not use this feature, or is this function containing a bug? And in this case, is my above modification respecting the PDF standards, about which I know nothing?

Regards

Offline

#2 2019-02-08 09:34:23

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

Re: Bug in the CreateHyperLink() function?

I have just found your post after fixing this error in the same way.

Offline

#3 2019-03-05 14:23:16

jeanmilost
Member
Registered: 2016-01-21
Posts: 35

Re: Bug in the CreateHyperLink() function?

@ab, several days ago I sent a push notification on the SynPDF GIT, which contains the above mentioned modification about hyperlinks, and also adds a new function, named CreateFileLink(), allowing to add a link to a file on the local computer, using an absolute or relative path. Can you please check, validate and (eventually) accept these modifications? Or if you decide to reject them, can you please inform me the reason, in order to allow me to recheck and correct my copy?

I also have the following questions:

  • My hyperlink works well now. However every time I click on it in Adobe PDF Reader, I receive a security notification popup dialog, asking me to confirm if I really want to open my file. Is there a way to trust the PDF in a such manner to no longer receive this notification? And if yes, how to do that?

  • Every time I click on my hyperlink, its background blinks to black. Is there a way to change this color?

Last edited by jeanmilost (2019-03-05 14:26:01)

Offline

#4 2020-05-26 07:17:37

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

Re: Bug in the CreateHyperLink() function?

Hello jeanmilost,

did you ever get an answer? What happened to your pull request?

Offline

#5 2020-05-26 09:43:40

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

Re: Bug in the CreateHyperLink() function?

Indeed it works, with that security message from Adobe Reader unfortunately.
Thanks!

Offline

Board footer

Powered by FluxBB