Make a rectagle or other shape as hyperlink

Hi, I'm testing PdfViewer for Wpf, I can load a pdf, add shapes, text and so on but how can I add a hyperlink so that when clicked I can navigate to a site or open a popup.. ? 
For example I wuold like to add a rectangle around a article-code then will open a popup in which I can set the url.
Thanks
Giovanni

3 Replies 1 reply marked as answer

VS Vikas Sekar Syncfusion Team October 5, 2020 04:57 PM UTC

Hi Giovanni, 
 
Thank you for contacting Syncfusion Support.  
 
At present, we do not have support to add hyperlink to loaded document directly. However, we have workaround to add hyperlinks using `LoadedDocument’. Please refer the below code to add hyperlinks to document in specific location on button click. 
 
private void Button_Click(object sender, RoutedEventArgs e) 
{ 
    PdfLoadedDocument loadedDocument = pdfViewer.LoadedDocument; 
 
    if (loadedDocument == null) 
        return; 
 
    //Load the page 
    PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; 
 
    //Create the font. 
    PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f); 
 
    //Create the Text Web Link. 
    PdfTextWebLink textLink = new PdfTextWebLink(); 
 
    //Set the hyperlink 
    textLink.Url = "http://www.syncfusion.com"; 
 
    //Set the link text 
    textLink.Text = "Click here for navigation"; 
 
    //Set the font 
    textLink.Font = font;            
 
    //Draw the hyperlink in loaded page graphics 
    textLink.DrawTextWebLink(loadedPage.Graphics, new System.Drawing.PointF(10, 40)); 
 
    MemoryStream memoryStream = new MemoryStream(); 
 
    //Save the document. 
    loadedDocument.Save(memoryStream); 
 
    pdfViewer.Load(memoryStream); 
} 
 
We have created a sample for the same and it can be downloaded from below link,  
 
Regarding Popup note in rectangle shape annotation: In PdfViewer we have support to add text content in Pop-up note for rectangle annotation. Using this we can include URL to the pop-up note content. Please refer the below UG link for popup note in rectangle shape annotation. 
 
 
Please let us know whether the above solution helps to achieve your requirement. Otherwise, please provided us more details about your requirement for further assistance. 
 
 
Regards, 
Vikas 


Marked as answer

GF Giovanni Finocchio October 5, 2020 05:22 PM UTC

Thank you for your response, 
what I mean is: clicking on a "HLink" button in the toolbar it could be possible visually draw a rectangle around a text and in a in-line popup write the url, close popup end.
Then the user open the pdf and can only click on the rectangle I create, to navigate some where in the web or make a post to a web api service.

Ok I can see that for now is not possible,
do you think this function can be scheduled to be done in next releases?

Thank you so much
Giovanni


VS Vikas Sekar Syncfusion Team October 6, 2020 03:52 PM UTC

Hi Giovanni, 
 
Thank you for providing detail information.   
 
We have analyzed your requirement which was similar to “Adding rectangle border for hyperlink as on Acrobat”. As this feature is not available in our product, we will consider this a feature request. If you could confirm some specific details, it would help us to implement the feature in line with your requirement. This feature has limitation that hyperlink can only have rectangle border, else we can’t apply hyperlink for shapes.  
 
 
Please review the above video of the similar feature in Acrobat and let us know if it conforms to your requirement. If our definition of this feature is different from your requirement, then let us know the specific details, so that we can work towards fulfilling your requirement. 
 
Regards, 
Vikas 


Loader.
Up arrow icon