PDF Links
Enable clickable links in PDFs for internal navigation and external URLs
Basic Usage
The AnnotationLayer component automatically handles clickable links in PDFs, including both internal page references and external URLs:
Configuration Options
The AnnotationLayer component accepts several props to customize link behavior:
External Links
Control whether external links (http/https) should be clickable:
When externalLinksEnabled is false, external links will not be clickable.
Navigation Options
Customize how internal page links navigate:
Jump Options
- behavior:
"smooth"|"auto""smooth": Animated scroll to the target page"auto": Instant jump to the target page
- align:
"start"|"center"|"end""start": Aligns the target page to the top of the viewport"center": Centers the target page in the viewport"end": Aligns the target page to the bottom of the viewport
How It Works
The link functionality is powered by PDF.js's AnnotationLayer and Lector's LinkService:
- Link Detection: The
AnnotationLayerautomatically detects all link annotations in the PDF - Internal Links: Links to other pages in the same PDF are handled internally using the
LinkService - External Links: Links to external URLs open in a new browser tab
- Navigation: Internal navigation uses the
usePdfJumphook for smooth scrolling
Complete Example
Here's a complete example with all options:
Link Service API
For advanced use cases, you can access the LinkService directly:
Styling Link Hovers
Links are automatically styled with hover effects. You can customize this with CSS:
Form Fields
The AnnotationLayer also supports interactive form fields. To enable form rendering:
This allows users to fill out PDF forms directly in the viewer.
