- Code: Select all
using var doc = new PdfDocument();
doc.LoadFromFile(docPath);
foreach (PdfPageBase page in doc.Pages)
{
foreach(PdfTextWebLinkAnnotationWidget link in page.AnnotationsWidget)
{
var linkUrl = link.Url;
linkUrl.AddQueryParam("refId", model.Meta.ReferrerId ?? refId)
.SetQueryParam("utm_campaign", "referral")
.SetQueryParam("utm_source", "handout01")
.SetQueryParam("utm_medium", "pdf");
link.Url = linkUrl;
}
}
On line with getting current value of link.Url I get a System.NullReferenceException. I can not read the property. If I try only to set the link.Url to "google_com" all links in the PDF will get updated to that value.
Why can't I read the link.Url property? How to alter the current link? I habe to take current value and add some query parameters to it.
Thanks and regards,
Sven