Technical Article

Add clickable hyperlinks to PDF files with HotPDF

· PDF Software

This HotPDF sample shows how to place clickable hyperlinks in a generated PDF document. Hyperlinks are a small feature, but they matter in invoices, reports, product sheets, documentation exports, and any PDF that should connect the reader back to a website, order page, support form, or online manual.

The important idea is that visible text and the clickable target are separate concerns. A PDF can display a friendly label while the annotation points to a full URL. In a real application, keep those two pieces synchronized so users can see where a link will take them.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
unit Main;
 
interface
 
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, StdCtrls, Forms, Dialogs, HPDFDoc;
 
type
  TForm1 = class(TForm)
    HotPDF: THotPDF;
    HelloWorldButton: TButton;
    edtWeb: TEdit;
    edtProduct: TEdit;
    edtOrder: TEdit;
    edtContact: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    procedure HelloWorldButtonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.HelloWorldButtonClick(Sender: TObject);
begin
    HotPDF.BeginDoc;
    HotPDF.CurrentPage.SetFont( 'Microsoft Sans Serif', [], 13 );
 
    HotPDF.CurrentPage.TextOut(20,30,0,'Clickable links:');
    HotPDF.CurrentPage.PrintHyperlink(20, 60, 'Company site: ' + edtWeb.Text, edtWeb.Text);
    HotPDF.CurrentPage.PrintHyperlink(20, 80, 'Product page: ' + edtProduct.Text, edtProduct.Text);
    HotPDF.CurrentPage.SetRGBHyperlinkColor(clRed);
    HotPDF.CurrentPage.PrintHyperlink(20, 100, 'Purchase link: ' + edtOrder.Text, edtOrder.Text);
    HotPDF.CurrentPage.SetRGBHyperlinkColor(clBlue);
    HotPDF.CurrentPage.PrintHyperlink(20, 120, 'Contact form: ' + edtContact.Text, edtContact.Text);
 
    HotPDF.EndDoc;
end;
 
end.

Where this pattern fits

Use PDF hyperlinks for references that should remain active after the document is emailed, archived, or downloaded from a customer portal. Common targets include product pages, online manuals, release notes, issue trackers, invoices, license lookup pages, and document verification endpoints.

Placement and styling

PDF links are annotations placed over a page area. If you change the font, text position, scaling, or page coordinate system, verify that the clickable rectangle still matches the text the user sees. A link that is visually shifted by a few pixels can feel broken even when the URL itself is correct.

Color is also part of the user experience. Blue underlined text is still the clearest convention for a web link, but generated reports sometimes need a quieter style. If you use a custom color, keep the surrounding text explicit enough that the reader understands it is clickable.

Validation checklist

  • Use fully qualified HTTPS URLs for public documents.
  • Validate user-supplied URLs before writing them into a PDF.
  • Test links in more than one PDF viewer because annotation handling can differ between readers.
  • Check the clickable area after changing page size, margins, fonts, or scaling.
  • Do not hide important workflow actions behind link text alone; provide surrounding context in the PDF body.

SEO and document distribution note

When PDFs are published online, clear link labels help both users and search engines understand the relationship between the document and the linked resource. Prefer descriptive text such as product documentation or customer support portal instead of generic labels like click here.