在搜索字符串中的PDF文件 [英] Searching for a string in a pdf files

查看:121
本文介绍了在搜索字符串中的PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一所学校的项目,有几个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.

这篇关于在搜索字符串中的PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆