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.

Mon Apr 15, 2019 10:16 am

Hello,
I have a question: I would like to search for a text and as a result the page number or page numbers of pages in which the word stands.
Unfortunately, I have not found a code sample for VB.net as I could implement that.

Many Thanks

kkduke

kkduke
 
Posts: 1
Joined: Mon Apr 15, 2019 10:10 am

Mon Apr 15, 2019 10:53 am

Hi,

Thanks for your inquiry.
Below is the sample code for your kind reference. If there is any question, please feel free to write back.
Code: Select all
Dim pdf As New PdfDocument()
pdf.LoadFromFile("Sample.pdf")
Dim lists As New List(Of PdfTextFind())()

For Each page As PdfPageBase In pdf.Pages
    lists.Add(page.FindText("Spire").Finds)
Next page

For Each finds As PdfTextFind() In lists
    For Each find As PdfTextFind In finds
        Dim pageNumber As Integer = find.SearchPageIndex + 1
        Console.WriteLine("Page number:  {0}", pageNumber)
    Next find
Next finds

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1375
Joined: Tue Sep 27, 2016 1:06 am

Fri Apr 26, 2019 12:30 pm

Hi,

Greetings from E-iceblue.
Did my code help you?
Thanks in advance for your valuable feedback and time.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1375
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF