Hyperlink

Technical support for Spire.PDF

Moderator: iceblue support

Hyperlink

Postby DanKoppers » Thu Jul 11, 2013 10:10 am

Hi,

is it possible (if so, is there any sample code, or can you provide it?) to do the following tasks with Spire.PDF:

1) Enumerate all Hyperlinks and get the URL of the Hyperlink (i guess as the Text is seperate form the Link Annotation, it would be difficult to get the text)
2) Delete a Hyperlink within the PDF
3) Change the URL of the Hyperlink to something else (i.e. link to google.com changed to bing.com, without affecting the Text in PDF)

Regards

D
DanKoppers
 
Posts: 1
Joined: Thu Jul 11, 2013 9:06 am

Re: Hyperlink

Postby Gary.zhang » Fri Jul 12, 2013 8:53 am

Hello,

Thanks for your inquiry.
Please don't mind that I add the answers after your questions.
1) Enumerate all Hyperlinks and get the URL of the Hyperlink (i guess as the Text is seperate form the Link Annotation, it would be difficult to get the text)
Please refer to the code snippet below to get all Hyperlinks and the URL of the specific Hyperlink. Sorry that our Spire.Pdf doesn't support to get the text of the Hyperlink at present. But we have added the feature into our schedule. Once Spire.Pdf supports the feature, we will tell you.
Code: Select all
PdfDocument pdfdoc = new PdfDocument();
pdfdoc.LoadFromFile(string filename);
PdfPageBase page = pdfdoc.Pages[0];
// The code page.AnnotationsWidget gets all Hyperlinks in every page of PDF file
foreach(PdfTextWebLinkAnnotationWidget link in page.AnnotationsWidget)
{
    // Get the URL of the Hyperlink
    string url=link.Url;
}

2) Delete a Hyperlink within the PDF
We provide you two solutions to delete a Hyperlink. Please try the following code.
Code: Select all
// solution 1
PdfTextWebLinkAnnotationWidget hyperL = page.AnnotationsWidget[0] as PdfTextWebLinkAnnotationWidget;
page.AnnotationsWidget.Remove(hyperL);
//solution 2
page.AnnotationsWidget.RemoveAt(index);

3) Change the URL of the Hyperlink to something else (i.e. link to google.com changed to bing.com, without affecting the Text in PDF)
Please refer to the code as below to change the original url of the Hyperlink.
Code: Select all
PdfTextWebLinkAnnotationWidget link = page.AnnotationsWidget[index] as PdfTextWebLinkAnnotationWidget;
link.url="http://www.bing.com";



Sincerely,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1390
Joined: Thu Apr 04, 2013 1:30 am

Re: Hyperlink

Postby Gary.zhang » Wed Jul 17, 2013 9:59 am

Hello,

Have you tried these approaches? Has the issue been resolved? Could you please update the thread if convenience?

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1390
Joined: Thu Apr 04, 2013 1:30 am

Re: Hyperlink

Postby IceC » Tue Jul 23, 2013 10:29 am

Hello Daniel,

This is Ben.
Thank you for your waiting. Our Spire.Pdf supports to get the text of the Hyperlink now. We has released the new version of Spire.Pdf. Please download and test Spire.pdf hotfix 2.8.43(http://www.e-iceblue.com/downloads/hot_fix/spire.pdf_hotfix_2.8.43.zip). If there are any questions, please feel free to contact us.

Regards,
Benjamin
E-iceblue support team
User avatar
IceC
 
Posts: 1
Joined: Fri Jul 12, 2013 2:25 am


Return to Spire.PDF

Who is online

Users browsing this forum: No registered users and 0 guests