Interactive links with .href
Make text or image elements clickable in PDF output with the href parameter.
Updated
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#
parameterID.hrefFor multi-page templates:
pageN@parameterID.hrefBasic Usage#
Text Links#
{
"modifications": {
"cta_button.href": "https://example.com/signup"
},
"response": {
"format": "pdf"
}
}The text element cta_button becomes clickable, redirecting to the signup page.
Image Links#
{
"modifications": {
"logo.href": "https://company.com",
"banner.href": "https://company.com/products"
},
"response": {
"format": "pdf"
}
}Both image elements become clickable in the PDF.
Multi-Page PDFs#
Add different links to elements across pages:
{
"modifications": {
"page1@cta.href": "https://example.com/page1",
"page2@cta.href": "https://example.com/page2",
"page3@cta.href": "https://example.com/page3"
},
"response": {
"format": "pdf"
}
}Combining with Content & Styles#
You can combine .href with regular parameters and styling:
{
"modifications": {
"button": "Learn More",
"button.href": "https://example.com/learn",
"button.fontSize": "24px",
"button.color": "#0066cc",
"button.backgroundColor": "#f0f0f0"
},
"response": {
"format": "pdf"
}
}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:
https://example.comhttp://example.comhttps://example.com/path/to/pagehttps://example.com?param=valuehttps://subdomain.example.com
❌ Invalid URLs (ignored):
""(empty string)" "(whitespace only)not-a-url(missing protocol)ftp://example.com(unsupported protocol)mailto:hello@example.comandtel:+15550100(not supported)http://localhost:3000orhttp://192.168.1.10(local or private address)
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
- Public Address - Links to
localhost, private network addresses, and.localor.internalhosts are ignored
If a URL fails validation:
- The link is not applied, and no error is returned
- The element remains non-clickable but visually unchanged
Element Type Support#
The .href parameter only works with text and image elements:
✅ Supported (text and image elements):
{
"textElement.href": "https://example.com",
"imageElement.href": "https://example.com"
}❌ Not Supported (shape elements are ignored):
{
"rectangle.href": "https://example.com",
"circle.href": "https://example.com"
}Attempting to use .href on unsupported elements will:
- Add a warning to the response
- 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:
// Dangerous characters are escaped
"<script>alert('xss')</script>" → "<script>alert('xss')</script>"Error Handling#
Malformed URLs are skipped without breaking the render. For example, this link is ignored:
{
"link.href": "ht!tp://bad-url"
}The PDF generates successfully, but this particular link is not applied.
Real-World Examples#
Marketing Flyer with CTA#
{
"modifications": {
"headline": "Limited Time Offer!",
"cta_text": "Shop Now",
"cta_text.href": "https://store.example.com/sale",
"cta_text.fontSize": "28px",
"cta_text.color": "#ffffff",
"cta_text.backgroundColor": "#ff6600"
},
"response": {
"format": "pdf",
"type": "url"
}
}Product Catalog#
{
"modifications": {
"product1_image.href": "https://shop.com/products/item-1",
"product1_name": "Wireless Headphones",
"product1_name.href": "https://shop.com/products/item-1",
"product2_image.href": "https://shop.com/products/item-2",
"product2_name": "Smart Watch",
"product2_name.href": "https://shop.com/products/item-2"
},
"response": {
"format": "pdf"
}
}Multi-Page Report with References#
{
"modifications": {
"page1@source1.href": "https://research.com/paper/123",
"page1@source1": "[1] Latest AI Research",
"page2@source2.href": "https://research.com/paper/456",
"page2@source2": "[2] Machine Learning Advances",
"page3@source3.href": "https://research.com/paper/789",
"page3@source3": "[3] Neural Networks Study"
},
"response": {
"format": "pdf"
}
}Event Invitation#
{
"modifications": {
"event_name": "Annual Tech Conference 2024",
"register_button": "Register Now",
"register_button.href": "https://events.com/register/tech-2024",
"register_button.fontSize": "32px",
"register_button.backgroundColor": "#0066cc",
"website_link": "Visit Website",
"website_link.href": "https://events.com",
"website_link.fontSize": "16px"
},
"response": {
"format": "pdf",
"type": "binary"
}
}API Integration Examples#
REST API#
curl -X POST https://api.orshot.com/v1/studio/render \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateId": "your-template-id",
"modifications": {
"cta_button": "Get Started",
"cta_button.href": "https://example.com/signup",
"cta_button.fontSize": "24px",
"cta_button.color": "#ffffff",
"cta_button.backgroundColor": "#0066cc"
},
"response": {
"format": "pdf",
"type": "url"
}
}'Dynamic URL#
https://api.orshot.com/v1/studio/dynamic-url/product-card.pdf?templateId=YOUR_TEMPLATE_ID&product_name=Premium%20Headphones&product_name.href=https%3A%2F%2Fshop.com%2Fproduct%2F123&product_name.fontSize=28px&product_image.href=https%3A%2F%2Fshop.com%2Fproduct%2F123&sign=YOUR_SIGNATURECopy the signed URL from your template's Dynamic URL tab, then add your parameters. See Dynamic URLs.
Combining with AI Generation#
You can use .href together with .prompt for dynamic linked content:
{
"modifications": {
"title.prompt": "Create a call-to-action for a fitness app",
"title.href": "https://fitness-app.com/download",
"title.fontSize": "36px",
"title.color": "#00cc66"
},
"response": {
"format": "pdf"
}
}The AI generates appropriate CTA text, which then becomes clickable.
Testing Links#
Playground Testing#
- Open your template's Playground
- Add the
.hrefkeys to the request'smodifications - Set the response format to PDF
- Generate and download the PDF
- Open it in a PDF reader to test the 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:
JSON { "cta.href": "https://example.com?utm_source=pdf&utm_campaign=summer" }
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:
// Properly encode URLs with special characters
const encodedUrl = encodeURIComponent(
"https://example.com?param=value&other=123",
);
// Use in modifications
modifications["link.href"] = decodeURIComponent(encodedUrl);Next Steps#
- Learn about AI Content Generation
- Explore Dynamic Parameters Introduction
- Check PDF Options for additional PDF settings
Ready to automate?
Start rendering images, PDFs and videos from your templates in under 2 minutes. Free plan, no credit card.
Get your API key- Image, PDF and video generation via API
- Visual editor with AI and smart layouts
- Zapier, Make, MCP and 40+ integrations
- White-label embed for your own app
- 100 free credits a month, no credit card required