#1 2011-07-19 11:33:36

cricque
Member
Registered: 2011-07-14
Posts: 2

Hyperlinks in PDF Pages

Hello, again

Is there a way to embed hyperlinks into TGDIPages in the SQLLite reporter

Basically http://www.yoururl.com works and but basically I have some files linked and i wanted to link to files with a relative path and not a fixed one.
So I was thinking about hyperlinks instead of file://c:\myfile.txt smile

Offline

#2 2011-07-19 11:37:17

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

Re: Hyperlinks in PDF Pages

Links inside the documents are handled in the current implementation (i.e. bookmarks).

URLs are recognized by Acrobat Readers.

You could create a new CreateExternalLink method just like TPdfDocument.CreateLink, by following the PDF reference about such external links.

Offline

#3 2016-05-27 15:22:34

jonjbar
Member
Registered: 2012-12-27
Posts: 37

Re: Hyperlinks in PDF Pages

ab wrote:

You could create a new CreateExternalLink method just like TPdfDocument.CreateLink, by following the PDF reference about such external links.

Hello Arnaud,
I've written the following procedure to create external hyperlinks.
Even though I'm not a PDF expert, it looks like it is working even for complex links. Any feedback is welcome.
Hopefully this can be included as-is in SynPDF source code:

function TPDFDocument.CreateExternalLink(const ARect: TPdfRect; const anUrl: RawUTF8;
  BorderStyle: TPdfAnnotationBorder; BorderWidth: integer): TPdfDictionary;
var
  anAction: TPdfDictionary;
begin
  result := CreateAnnotation(asLink, ARect, BorderStyle, BorderWidth);
  anAction := TPdfDictionary.Create(FXRef);
  anAction.AddItem('Type', 'Action');
  anAction.AddItem('S', 'URI');
  anAction.AddItemTextUTF8('URI', anUrl);
  Result.AddItem('A', anAction);
end;

Offline

Board footer

Powered by FluxBB