- Home
- Forum
- ASP.NET Core - EJ 2
- Hyperlinks Visible but Not Clickable in PDF Generated Using Syncfusion HtmlToPdfConverter (Blink)
Hyperlinks Visible but Not Clickable in PDF Generated Using Syncfusion HtmlToPdfConverter (Blink)
Hi,
---
### **Environment**
* **Technology:** ASP.NET Core
* **HTML to PDF Converter:** Syncfusion HtmlToPdfConverter
* **Rendering Engine:** Blink
* **Output Format:** PDF (Base64 encoded for upload)
---
### **Description**
We are generating an HTML document that includes styling and anchor (`<a>`) tags. This HTML can span multiple pages and contains multiple sections with hyperlinks. The HTML is converted into a PDF using Syncfusion’s `HtmlToPdfConverter` with Blink converter settings.
Although the hyperlinks appear visually in the generated PDF, they are **not clickable**, even after enabling the `EnableHyperLink` property.
---
### **Sample HTML**
```html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Demo title</title>
</head>
<body>
<h1 class="chapterStyle"><strong>Overview and Executive Summary</strong></h1>
<h2 class="sectionStyle">Introduction</h2><a rel='nofollow' href="https://www.google.com"> ram gautam </a>
<h1 class="chapterStyle"><strong>Chapter 2</strong></h1>
<h2 class="sectionStyle">Introduction To chapter 2</h2>
<a rel='nofollow' href="https://www.github.com">
<p style="margin-left: 20px; text-align: inherit;">
<span style="background-color: unset; font-size: 1em; text-align: inherit;">
The National Incident Management System,
Third Edition, October 2017, Issued by FEMA at
www.fema.gov/sites/default/files/2020-07/fema_nims_doctrine-2017.pdf pages 61-71 represents the
terms and definitions utilized by NIMS.
</span>
</p>
</a>
</body>
</html>
```
---
### **CSS Used (`myCssForPdf`)**
```css
.chapterStyle {
font-family: Arial;
font-size: 32px;
page-break-before: always;
text-align: center;
}
.sectionStyle {
font-family: Arial;
font-size: 24px;
margin-top: 50px !important;
text-align: left;
}
```
---
### **Conversion Code**
```csharp
//Initialize HTML to PDF converter with Blink rendering engine.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
HtmlToPdfToc toc = new HtmlToPdfToc();
toc.TitleStyle.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
blinkConverterSettings.Toc = toc;
//Table of content property. Set it as true
blinkConverterSettings.EnableToc = true;
HtmlToPdfTocStyle style = new HtmlToPdfTocStyle();
style.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 10);
blinkConverterSettings.Toc.SetItemStyle(1, style);
blinkConverterSettings.Toc.SetItemStyle(2, style);
blinkConverterSettings.Toc.SetItemStyle(3, style);
blinkConverterSettings.Toc.SetItemStyle(4, style);
blinkConverterSettings.Toc.SetItemStyle(5, style);
blinkConverterSettings.Toc.SetItemStyle(6, style);
//Page size - A4 (8.27 * 11.69 inches) using 72 Twips per inch
blinkConverterSettings.PdfPageSize = new Syncfusion.Drawing.SizeF(595, 842);
//Set PDF page orientation
blinkConverterSettings.Orientation = PdfPageOrientation.Portrait;
//Add margins - using 72 Twips per inch
blinkConverterSettings.Margin.Top = 40;
blinkConverterSettings.Margin.Bottom = 40;
blinkConverterSettings.Margin.Right = 0;
blinkConverterSettings.Margin.Left = 0;
blinkConverterSettings.Scale = 0.6f; //set the content size in pdf
//Set Blink viewport size
blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(523, 770);
// MUST be set to true to preserve clickable links
blinkConverterSettings.EnableHyperLink = true;
//Assign Blink converter settings to HTML converter.
htmlConverter.ConverterSettings = blinkConverterSettings;
//htmlConverter.ConverterSettings.EnableHyperLink = true;
string styleString = _configuration['myCssForPdf'];
// Enclose in style tag
string cssStyle = $"<style>{styleString}</style>";
if (htmlText.Contains("</head>"))
{
htmlText = htmlText.Replace("</head>", cssStyle + "</head>");
}
//Console.WriteLine("CompltedHtml : "+ htmlText.ToString());
htmlText = htmlText + "</body></html>";
//Convert HTML to PDF.
PdfDocument document = htmlConverter.Convert(htmlText, string.Empty);
PdfDocument pdfDocument = new PdfDocument();
for (int i = 0; i < document.Pages.Count; i++)
{
//Get loaded page as template
Syncfusion.Pdf.Graphics.PdfTemplate template = document.Pages[i].CreateTemplate();
//Create new page
PdfPage page = pdfDocument.Pages.Add();
//Draw template with the size as loaded page size
page.Graphics.DrawPdfTemplate(template, Syncfusion.Drawing.PointF.Empty, page.GetClientSize());
}
//Save the document into stream.
MemoryStream memoryStream = new MemoryStream();
//Save and Close
pdfDocument.Save(memoryStream);
PdfDocument document1 = HeaderFooter(memoryStream, versionNumber, generateMode, Owner, Name, releaseDateTimeUtc);
// Save the modified document to a memory stream
MemoryStream modifiedStream = new MemoryStream();
document1.Save(modifiedStream);
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(modifiedStream);
MemoryStream stream = new MemoryStream();
loadedDocument.Save(stream);
string base64String = Convert.ToBase64String(stream.ToArray());
// Close the documents
pdfDocument.Close();
document1.Close();
loadedDocument.Close();
// Return the Base64 string
return base64String;
```
---
### **Expected Result**
Hyperlinks in the generated PDF should be clickable and redirect to the specified URLs.
---
### **Actual Result**
Hyperlinks are visible in the PDF but are not clickable.
---
### **Additional Notes**
* `EnableHyperLink` is explicitly set to `true`.
* The PDF is post-processed (header/footer addition) and finally returned as a Base64 string for upload.
* The issue persists even after returning the Base64-encoded PDF.
---
### **Request**
Please advise whether:
* Any additional settings are required to preserve clickable hyperlinks when using Blink.
* Post-processing of PDF pages/templates affects hyperlink annotations.
* This is a known limitation or requires a workaround.
---
Hi Bharat,
Thank you for
reaching out to Syncfusion support.
We have reviewed the reported issue on our end. After further analysis, we were able to replicate the problem, the hyperlinks are not working in the output PDF document. You generated a PDF document from HTML content using our HtmlConverter library. After generating the PDF, it appears that you created another PDF document and drew the content into this new document as a PDF template, which caused the link annotations to be lost. This is why the hyperlinks in the final output PDF are not functioning as expected.
Before
drawing the PDF template into a new document, you need to collect the link
annotations from the original document and restore them into the newly created
document. This ensures that the hyperlinks are retained and work as
expected.
To
address the reported issue, we have created a sample console application that
demonstrates how to generate a PDF using the HtmlConverter library and then retrieve and
restore the annotations. For your reference, please see the following modified
code snippet:
Code
Snippet:
|
Dictionary<int, List<PdfLoadedAnnotation>> keyValuePairs = new Dictionary<int, List<PdfLoadedAnnotation>>(); var annotations = loadedDocument.Pages[i].Annotations; List<PdfLoadedAnnotation> pdfLoadedAnnotations = new List<PdfLoadedAnnotation>(); foreach (PdfLoadedAnnotation annotation in annotations) { if (annotation.Type is PdfLoadedAnnotationType.TextWebLinkAnnotation || annotation.Type == PdfLoadedAnnotationType.DocumentLinkAnnotation) { pdfLoadedAnnotations.Add(annotation); //retrieve the link annotations } keyValuePairs[i] = pdfLoadedAnnotations; } if (keyValuePairs?.Count > 0) { float pageMargin = 10; // Add annotations to the page List<PdfLoadedAnnotation> annotations1 = new List<PdfLoadedAnnotation>(); keyValuePairs.TryGetValue(i, out annotations1); if (annotations1 != null) { foreach (PdfLoadedAnnotation annotation in annotations1) { PdfLoadedTextWebLinkAnnotation pdfLoadedTextWebLinkAnnotation = annotation as PdfLoadedTextWebLinkAnnotation; annotation.Bounds = new RectangleF(annotation.Bounds.X, annotation.Bounds.Y - pageMargin, annotation.Bounds.Width, annotation.Bounds.Height); PdfUriAnnotation pdfUriAnnotation = new PdfUriAnnotation(annotation.Bounds, pdfLoadedTextWebLinkAnnotation.Url); pdfUriAnnotation.Text = pdfLoadedTextWebLinkAnnotation.Text; pdfUriAnnotation.Border = annotation.Border; page.Annotations.Add(pdfUriAnnotation); //add the link annotations } } } |
Please find the attached modified sample along with the output PDF document.
We also recommend adding headers and footers directly in the BlinkConverter using the HtmlHeader, HtmlFooter, PdfHeader, and PdfFooter properties. By using these properties, you can avoid such discrepancies altogether. For more details, please refer to the following documentation:
- HTML to PDF converter features in .NET PDF Library | HTML Header and Footer | Syncfusion
- HTML to PDF converter features in .NET PDF Library | Pdf Header and FooterSyncfusion
We
suggest running the modified sample and letting us know the results. We look
forward to hearing from you and confirming whether the provided solution meets
your requirements.
Regards,
Arumugam M
Attachment: HTMLtoPDFSample_a06d3a06.zip
I tried adding the annotations as suggested in the ticket solution. I also attempted using ImportPage instead of CreateTemplate, but the issue still persists.
Additionally, the demo code you provided is not working in our environment due to the following differences:
Target Framework
Your demo targets .NET 9.0, whereas our application targets .NET 8.0. This results in the following error:NETSDK1045: The current .NET SDK does not support targeting .NET 9.0. Either target .NET 8.0 or lower.Syncfusion Package Version
In our project, we are using the package Syncfusion.HtmlToPdfConverter.Net.Windows (Version29.2.11).
However, the demo appears to be built with a different syncfusion version(
32.1.21).
Please let us know if the solution can be validated for .NET 8.0 using the same Syncfusion package version we are currently on, or if any additional changes are required.
Hi Bharat,
We have checked the reported issue on our end. Upon further analysis, as you mentioned, we have downgraded our sample .NET and Syncfusion package version from .NET 9.0 to .NET 8.0 and from 32.1.21 to 29.2.11 respectively to ensure whether the hyperlink in the output PDF document is working or not. We are now able to replicate the reported issue (hyperlink is not working) in the output PDF document. This issue has already been identified and fixed. To overcome the reported issue, we recommend that you use the latest Syncfusion HtmlConverter package version.
We have modified the provided sample with the .NET 8.0 runtime using our latest version, and the hyperlink is working as expected. Please find the sample attached.
Please review this information and try running the sample on your end, and let us know the results. Kindly get back to us if you need any further assistance with this.
Regards,
Arumugam M
Attachment: HTMLtoPDFSample_ede4f732.zip
- 3 Replies
- 2 Participants
-
BB Bharat Bharat
- Jan 2, 2026 07:05 AM UTC
- Jan 19, 2026 12:32 PM UTC