Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Jan 03, 2018 1:38 pm

Hello Team,

I need to get the text from pdf file and replace that text with hyperlink so that I can open a new pdf from that hyperlink.

Below is my requirement.

I have a Index.pdf file which have 5 rows with the following data
Document1
Document2
Document3
Document4
Document5

Now I want to replace this text with hyperlink or any other link which will be suitable to open new pdf file and when anyone click on that hyperlink he will redirect to new pdf file that is mentioned in hyperlink.

Thanks,
Naveen Sharma

naveen.sha
 
Posts: 4
Joined: Thu Dec 21, 2017 7:29 am

Thu Jan 04, 2018 3:08 am

Hello,

Thanks for your inquiry.
Please refer to the below code to accomplish your task. Take document 1 as an example.
Code: Select all
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(@"Index.pdf");

PdfTextFind[] result = null;
foreach (PdfPageBase page in pdf.Pages)
{
    result = page.FindText("Document1").Finds;
    foreach (PdfTextFind find in result)
    {
        PdfLaunchAction launchAction = new PdfLaunchAction(@"document1.pdf", PdfFilePathType.Absolute);
        RectangleF rect = new RectangleF(find.Position.X - pdf.PageSettings.Margins.Left,
            find.Position.Y - pdf.PageSettings.Margins.Top, find.Size.Width, find.Size.Height);
        PdfActionAnnotation annotation = new PdfActionAnnotation(rect, launchAction);
        annotation.Border = new PdfAnnotationBorder(0);
        (page as PdfPageWidget).AnnotationsWidget.Add(annotation);
    }
}
pdf.SaveToFile("hyperlink.pdf");


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Thu Jan 04, 2018 5:58 am

Hello ,

Thanks for your reply

Following are the requirements for evaluation of PDF in our project

1) There is a folder (ex like “documents”) in which we have six PDF files like
a)Document1.pdf
b)Document2.pdf
c)Document3.pdf
d)Document4.pdf
e)Document5.pdf
f) Index.pdf

2) Now from the index file we want to make a replica of an Index PDF file (Like images, text(content))
When we will create a replica of INDEX PDF file and save with an another name we want the whole content to be behave like
a hyperlink.

in new replica PDF. Like in INDEX.PDF file there will a content of like index of book or content which will be in a list form
e.g: 1) document1 --Hyperlink of document1
2)documen2 --- Hyperlink of document2
3)document3 --- Hyperlink of document3
4)document4 ---Hyperlink of document4

3) When we click on that hyperlinks and it should open a new PDF File.

4) There is a last requirement we also want to create bookmarks that will redirect to external pdf files and we also want to
merge that bookmarks with already existing bookmarks and not to replace with the newly created bookmarks. .

But when we create bookmarks for all PDF files which are in document folder it creates bookmarks but if there are already bookmarks so while creating bookmarks we want to merge that bookmarks with already existing bookmarks and not to replace with the newly created bookmarks.

If there are solutions for our each query or requirement so please provide the sample code or any help document for the same asap. Because I have to implement this all functionalities in our project.

Kindly mention the product price which include all these functionalities and duration of the same.

Thanks and regards
Naveen Sharma

naveen.sha
 
Posts: 4
Joined: Thu Dec 21, 2017 7:29 am

Thu Jan 04, 2018 8:09 am

Hello,

Thanks for your response.
Concerning the first three points, I made a demo for you according to your description. Please download at http://www.e-iceblue.com/downloads/attachment/12536.zip. If it is not what you want, please provide the desired pdf file and share more details.
As for the point 4, sorry I am a little confused, what do you mean by "merge bookmarks", is it updating the existing bookmarks or anything else? Could you please send the sample pdf file and the related code to us([email protected]) for better demonstrating the issue?
Besides, please check the price details of Spire.PDF as below:
https://www.e-iceblue.com/Buy/Spire.PDF.html
and details of the purchase policy including the duration:
https://www.e-iceblue.com/Misc/purchase-policies.html

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.PDF

cron