C# 如何在C中搜索pdf中的文本(执行匹配)#
我的申请书结巴了。我想通过c#中的axacropdf控件搜索文本(精确匹配)和位置,并突出显示pdf中的文本。我怎样才能做到这一点。我在谷歌上搜索了很多主题,但没有任何帮助。我怎样才能达到这个目标。你有没有这方面的代码或dll。请给我一些密码C# 如何在C中搜索pdf中的文本(执行匹配)#,c#,visual-studio-2008,.net-3.5,adobe-reader,axacropdf,C#,Visual Studio 2008,.net 3.5,Adobe Reader,Axacropdf,我的申请书结巴了。我想通过c#中的axacropdf控件搜索文本(精确匹配)和位置,并突出显示pdf中的文本。我怎样才能做到这一点。我在谷歌上搜索了很多主题,但没有任何帮助。我怎样才能达到这个目标。你有没有这方面的代码或dll。请给我一些密码 感谢使用Bytescout.PDFExtractor try { if (openFileDialog1.ShowDialog() == DialogResult.OK) {
感谢使用Bytescout.PDFExtractor
try
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
FileName = openFileDialog1.FileName;
string FName = FileName;
int a = FileName.LastIndexOf('\\');
txtFileName.Text = FileName.Substring(a + 1);
axAcroPDF1.LoadFile(FileName);
FileInfo fi = new FileInfo(FileName);
string PDFFileName = fi.Name.ToString();
double filesize = (fi.Length / 1024F / 1024F);
string size = filesize.ToString("0.00 MB");
string CreationDate = fi.CreationTime.ToString();
string LastAccessDate = fi.LastAccessTime.ToString();
string ModifiedDate = fi.LastWriteTime.ToString();
lblVersion.Text = "File Name : " + PDFFileName + "\nSize : " + size + "\nCreation Date : " + CreationDate + "\nModified Date : " + ModifiedDate;
TextExtractor extractor = new TextExtractor();
extractor.RegistrationName = "Demo";
extractor.RegistrationKey = "Demo";
extractor.LoadDocumentFromFile(FileName);
int pageCount = extractor.GetPageCount();
RectangleF location;
for (int s = 0; s <= Keywords.Length - 1; s++)
{
if (Keywords[s] != "")
{
TreeNode tNode = new TreeNode();
tNode = treeView1.Nodes.Add(Keywords[s]);
for (int i = 0; i < pageCount; i++)
{
if (extractor.Find(i, Keywords[s], false, out location))
{
do
{
int j = i;
tNode.Nodes.Add((j+1).ToString() + " " + location.ToString());
float X = location.X;
float Y = location.Y;
float Width = location.Width;
float Height = location.Height;
float Left = location.Left;
float Right = location.Right;
float Top = location.Top;
float Bottom = location.Bottom;
//axAcroPDF1.setCurrentHighlight(Convert.ToInt32(X), Convert.ToInt32(Y), Convert.ToInt32(Width), Convert.ToInt32(Height));
}
while (extractor.FindNext(out location));
}
}
}
else
{
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
试试看
{
如果(openFileDialog1.ShowDialog()==DialogResult.OK)
{
FileName=openFileDialog1.FileName;
字符串FName=文件名;
int a=FileName.LastIndexOf('\\');
txtFileName.Text=FileName.Substring(a+1);
axAcroPDF1.LoadFile(文件名);
FileInfo fi=新的FileInfo(文件名);
字符串PDFFileName=fi.Name.ToString();
双文件大小=(fi.Length/1024F/1024F);
字符串大小=filesize.ToString(“0.00MB”);
字符串CreationDate=fi.CreationTime.ToString();
字符串LastAccessDate=fi.LastAccessTime.ToString();
字符串ModifiedDate=fi.LastWriteTime.ToString();
lblVersion.Text=“文件名:”+PdfileName+“\n大小:”\n创建日期:“+CreationDate+”\n修改日期:“+ModifiedDate;
TextExtractor extractor=新的TextExtractor();
extractor.RegistrationName=“Demo”;
extractor.RegistrationKey=“Demo”;
extractor.LoadDocumentFromFile(文件名);
int pageCount=extractor.GetPageCount();
矩形定位;
对于(int s=0;s),我已使用bytescout.pdfextractor dll执行此任务,它已成功搜索所需文本。感谢您的合作。