WPF XAML to PDF - How do I keep URL links active in PDF?


I have a hyperlink in my XAML just like your example flowdocument3.xaml (http://www.pdftron.com/pdfnet/samplecode.html#Xaml2Pdf). When converted to PDF the hyperlink is not selectable in the PDF. Any suggestions?

My Xaml is:

<Paragraph Margin=“0,0,0,0” Padding=“0,0,0,0” TextAlignment=“Left”>
<Hyperlink NavigateUri="

http://www.foxnews.com">SX 820.3 - 820.8


The Xaml2PDF sample does not automatically create hyperlinks. You can add links to a PDF document programmatically, as shown by the Annotation sample (http://www.pdftron.com/pdfnet/samplecode.html#Annotation).

To clarify, after you create a PDF you can use ‘pdftron.PDF.TextSearch()’ to search for any URL-s via regular expressions. This will give you a list of rectangles and URL strings that you can use to add Hyperlink annotations as shown in the Annotation sample.

To recognize URL links as well as email addresses use the following regex search pattern:

pattern = “((?:(?:https?|ftp|file)://|www\.|ftp\.)(?:\([-A-Z0-9+&@#/%=~|$?!:,.]*\)|[-A-Z0-9+&@#/%=~|$?!:,.])(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]\)|[A-Z0-9+&@#/%=~|$]))|([a-z0-9!#$%&’*+/=?^{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)[@(?:a-z0-9?\.)+a-z0-9?)](mailto:@(?:a-z0-9?\.)+%5ba-z0-9%5d(?:%5ba-z0-9-%5d*%5ba-z0-9%5d)?))”;

in TextSearch (http://www.pdftron.com/pdfnet/samplecode/TextSearchTest.cs)