Interactive Links with .href
Add clickable links to text and image elements in PDF outputs using the .href parameter
Overview
The .href parameter adds clickable hyperlinks to text and image elements in PDF outputs. When users click on these elements in the generated PDF, they'll be redirected to the specified URL.
PDF Only Feature: Links only work in PDF format outputs. They are ignored for PNG, JPEG, and WebP formats.
How It Works
When you add .href to a parameterized text or image element, Orshot:
- Validates the URL format
- Applies the link as a clickable area in the PDF
- Preserves all visual styling while making the element interactive
Syntax
For multi-page templates:
Basic Usage
Text Links
The text element cta_button becomes clickable, redirecting to the signup page.
Image Links
Both image elements become clickable in the PDF.
Multi-Page PDFs
Add different links to elements across pages:
Combining with Content & Styles
You can combine .href with regular parameters and styling:
The button shows "Learn More" text, styled with custom colors and font size, and links to the specified URL.
URL Validation
Orshot validates URLs to ensure they're properly formatted:
✅ Valid URLs:
❌ Invalid URLs (ignored):
Validation Rules
- Non-empty - Must contain actual content
- Valid Protocol - Must use
http://orhttps:// - Valid Domain - Must have a proper hostname with TLD
- Proper Format - Must be parseable as a valid URL
If a URL fails validation:
- A warning is logged
- The link is not applied
- The element remains non-clickable but visually unchanged
Element Type Support
The .href parameter only works with text and image elements:
✅ Supported:
❌ Not Supported:
Attempting to use .href on unsupported elements will:
- Log a warning
- Skip the link application
- Render the element normally without a link
Security & Safety
XSS Protection
All href values are automatically sanitized to prevent XSS attacks:
Error Handling
Malformed URLs are caught and logged without breaking the render:
The PDF generates successfully, but this particular link is not applied.
Real-World Examples
Marketing Flyer with CTA
Product Catalog
Multi-Page Report with References
Event Invitation
API Integration Examples
REST API
Dynamic URL
Combining with AI Generation
You can use .href together with .prompt for dynamic linked content:
The AI generates appropriate CTA text, which then becomes clickable.
Testing Links
Playground Testing
- Open your template in Orshot Studio
- Navigate to the Playground tab
- Add
.hrefparameters in the Dynamic Parameters section - Set response format to PDF
- Generate and download the PDF
- Open in a PDF reader to test links
Limitations & Best Practices
Limitations
- PDF Only - Links are ignored in PNG, JPEG, and WebP outputs
- Element Types - Only text and image elements support links
- URL Format - Must be valid http/https URLs
- Click Area - Entire element becomes clickable (not individual words)
Best Practices
- Always Validate URLs - Use
https://for security - Test Link Functionality - Verify links in actual PDF readers
- Use Descriptive Text - Make link purpose clear
- Combine with Visual Cues - Use colors/styling to indicate clickability
- Track Link Usage - Use URL parameters for analytics:
Troubleshooting
Links Not Working
Issue: Generated PDF doesn't have clickable links
Solutions:
- Verify response format is
"pdf"(not"png"or"jpeg") - Check URL validation - must be valid http/https URLs
- Ensure element type is text or image (not shape)
- Test in different PDF readers (some readers have link restrictions)
Link Goes to Wrong URL
Issue: Link redirects to unexpected URL
Solutions:
- Check for typos in the URL
- Ensure URL encoding in dynamic URLs
- Verify no conflicting
.hrefparameters - Check for page-specific prefixes in multi-page templates
URL Encoding Issues
Issue: Special characters break the link
Solutions:
Next Steps
- Learn about AI Content Generation
- Explore Dynamic Parameters Introduction
- Check PDF Options for additional PDF settings