在搜索字符串中的PDF文件字符串、文件、PDF

2023-09-04 00:20:38 作者:可惜不是你

我工作的一所学校的项目,有几个PDF文件。应该有按名称的功能,我只需键入学生的名字和所有与他/她的名字的PDF文件应该打开搜索。什么是做到这一点的最好方法是什么?我已经看过了网上的解决方案和所有我来了是iTextSharp的,它的制作比较迷茫。

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.

推荐答案

使用iTextSharp的。它是免费的,你只需要itextsharp.dll。

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

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

下面是一个简单的函数读取文本从一个PDF的。

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.