image with hyperlink

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v10)  /  image with hyperlink

DynamicPDF CoreSuite for .NET (v10) Forum

 Mar 24 2020 10:29 AM
Hi,

How do I create an image that when clicked navigates to a specified url?

Cheers,
Frank.
 Mar 24 2020 1:32 PM
Posted by a ceTe Software moderator
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
 Mar 24 2020 1:35 PM
Thanks for the quick response!

 Mar 26 2020 6:01 AM
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?
 Mar 26 2020 9:58 AM
Posted by a ceTe Software moderator
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

All times are US Eastern Standard time. The time now is 12:45 PM.