Click here to Skip to main content
14,641,850 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all,
I am just about to pull my last hairs out. Does anyone know of how to create a function or some line or two of code that actually searches ALL text within a PDF or DOC? I have been playing around with all sorts of ideas but have never came across this one. I do not want to search the title, I need to search the actual text in the body of these two file types. I hope this makes sense?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can't do it in one function!

I can't help you in ASP.NET, but i can explain it in VB.NET ;)

To search MS Word's documents use build-in in MS Word application Find.Execute[^] method.
There are two methods to create MS Word application:
1) using Interop.Services
2) using OLE.

In the first case you need to add reference to Interop.Serices and write code like this:
Dim wrdApp = New Word.Application

The advantage is: client's computers does not need MS Word application.

In the second case you need to create MS Word application like this:
Dim wrdApp As Object = Nothing
wrdApp = CreateObject("Word.Application")

Now you have access to all methods and functions in MS Word ;)
The disadvantage of this approach is the requirement to install MS Word on the client's computers.

Read more about: early/late bound[^].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100