image with hyperlink

image with hyperlink

Forum member · Mar 24, 2020
Hi, How do I create an image that when clicked navigates to a specified url? Cheers, Frank.

Re: image with hyperlink

Support · Mar 24, 2020
Hello, You can add links to a PDF using the Link page element and add an image to the PDF using the Image page element. Please refer to the documentation on Image page element here . You can add a link on the image by specifying the image’s dimension and positions. The documentation on the Link page element is found here . You can set a URL for the link using UrlAction class. Below is a code sample. Document document = new MergeDocument(); Page MyPage = new Page(); document.Pages.Add(MyPage); Image MyImage=new Image(@"Image file path",100,100); MyImage.Width=50; MyImage.Height=50; UrlAction action2 = new UrlAction("http://www.dynamicpdf.com"); Link MyLink2 = new Link(MyImage.X, MyImage.Y, MyImage.Width, MyImage.Height, action2); // Add the label and the link to the page MyPage.Elements.Add(MyImage); MyPage.Elements.Add(MyLink2); document.Draw(@"C:\temp\MyDocument.pdf"); Thanks, ceTe Software Support Team

Re: image with hyperlink

Forum member · Mar 24, 2020
Thanks for the quick response!

Re: image with hyperlink

Forum member · Mar 26, 2020
At the moment the link opens up in the same tab... Is there any way to make the link open up a new browser tab?

Re: image with hyperlink

Support · Mar 26, 2020
Hello, Opening a web page when clicking a link is dependent on the browsers PDF Viewer. There is no property or method available in the DynamicPDF API to make a link to open in a new tab of the browser. Thanks, ceTe Software Support Team