Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching for a string in a pdf files

I am working on a school project that has several pdf files. There should be a search by name functionality that I just type in the student's name and all the pdf files with his/her name should open. What is the best way to do this? I've looked for solutions on the net and all I am coming up with is iTextSharp and it's making more confused.

Is this possible? Maybe someone can please give me a link to a tutorial, or something. :) Thank you very much.

like image 291
Anttette Avatar asked Feb 12 '11 11:02

Anttette


1 Answers

Use iTextSharp. It's free and you only need the "itextsharp.dll".

http://sourceforge.net/projects/itextsharp/

Here is a simple function for reading the text out of a PDF.

Public Shared Function GetTextFromPDF(PdfFileName As String) As String
    Dim oReader As New iTextSharp.text.pdf.PdfReader(PdfFileName)

    Dim sOut = ""

    For i = 1 To oReader.NumberOfPages
        Dim its As New iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy

        sOut &= iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(oReader, i, its)
    Next

    Return sOut
End Function

Now you can search through those files with ease.

like image 54
Carter Medlin Avatar answered Oct 03 '22 15:10

Carter Medlin