eDocEngine VCL Professional Help » Symbol Reference » Namespaces of Helper Classes » gtExPDFEng Namespace » TgtPDFLinkAnnot Class

Gnostice eDocEngine VCL Developer Guide
TgtPDFLinkAnnot Class

This class represents a link annotation.

Pascal
public TgtPDFLinkAnnot = class(TgtPDFAnnot);
C++
public: class TgtPDFLinkAnnot : public TgtPDFAnnot;
Description

A link annotation is typically used to link to another destination in a document. However, it can be used to make viewer applications execute any PDF action.

gtExPDFEng

procedure TForm1.Demo_TgtPDFLinkAnnot;
var
  gtPDFLinkAnnot1, gtPDFLinkAnnot2: TgtPDFLinkAnnot;
  gtAnnotGoToAction1: TgtAnnotGoToAction;
  gtAnnotLinkAction1: TgtAnnotLinkAction;
  gtPDFEngine1: TgtPDFEngine;
begin
  gtPDFEngine1 := TgtPDFEngine.Create(Nil);

  with gtPDFEngine1 do
  begin
    Preferences.ShowSetupDialog := False;
    Preferences.OpenAfterCreate := True;
    FileName := 'link_annotation.pdf';

    // Create a PDF document
    BeginDoc;

    // Write link text on page 1
    Font.Color := clBlue;
    TextOut(1, 1, 'Page 2');
    Font.Color := clBlack;

    // Create a go-to action
    gtAnnotGoToAction1 := TgtAnnotGoToAction.Create;
    gtAnnotGoToAction1.Page := 2;

    // Create a link annotation with the go-to action
    gtPDFLinkAnnot1 := TgtPDFLinkAnnot.Create;
    gtPDFLinkAnnot1.Rect :=
       gtRect(1, 0.9, // Top-right corner of link text
              1 + TextSize('Page 2', Font).cx/96,  1.2);  // Width of link text
    gtPDFLinkAnnot1.BorderWidth := 1;
    gtPDFLinkAnnot1.Action := gtAnnotGoToAction1;

    // Add the link annotation to page 1
    AddAnnotItem(gtPDFLinkAnnot1);

    // Write link text on page 2
    NewPage;
    TextOut(1, 1, 'Website: ');
    Font.Color := clBlue;
    TextOut(2, 1, 'www.gnostice.com');
    Font.Color := clBlack;

    // Create a URI action
    gtAnnotLinkAction1 := TgtAnnotLinkAction.Create;
    gtAnnotLinkAction1.URI := 'http://www.gnostice.com/';

    // Create a second link annotation with the above URI action
    gtPDFLinkAnnot2 := TgtPDFLinkAnnot.Create;
    gtPDFLinkAnnot2.Rect :=
             gtRect(2,
                    0.9,
                    2 + TextSize('www.gnostice.com', Font).cx/96,
                    1.2);
    gtPDFLinkAnnot2.BorderWidth := 1;
    gtPDFLinkAnnot2.Action := gtAnnotLinkAction1;

    // Add the second link annotation to page 2
    AddAnnotItem(gtPDFLinkAnnot2);

    // Save the PDF document
    EndDoc;
  end;

end;

 

Properties
TgtPDFLinkAnnot Class
 
Name 
Description 
 
Specifies action that needs to be executed by viewer application when the user selects or interacts with the annotation. 
 
Specifies border color of the annotation. 
 
Specifies width of the border of the annotation. 
 
Specifies highlight mode that viewer application should display when the user hovers the mouse pointer over the annotation. 
 
Rect 
Specifies the location of the annotation on its page. 
Methods
TgtPDFLinkAnnot Class
 
Name 
Description 
 
Creates a new instance of this class. 
 
Destroys this instance.