2012-04-22 3 views

답변

1

뭔가 작업을해야합니다 :

// add any string you want to match on 
Regex regex = new Regex("the", 
    RegexOptions.IgnoreCase | RegexOptions.Compiled 
); 
PdfReader reader = new PdfReader(pdfPath); 
PdfReaderContentParser parser = new PdfReaderContentParser(reader); 
for (int i = 1; i <= reader.NumberOfPages; i++) { 
    ITextExtractionStrategy strategy = parser.ProcessContent(
    i, new SimpleTextExtractionStrategy() 
); 
    if (regex.IsMatch(strategy.GetResultantText())) { 
    // do whatever with corresponding page number i... 
    } 
} 
1

현재 페이지 번호를 찾을 수 Acrobat.dll을 사용할 수 있습니다 Itextsharp을 사용하려면. 우선은 pdf 파일을 열고이 PDF 파일에있는 문자열이 다음 커서가 특정 페이지로 이동하고 검색 문자열이 강조 될 경우 문자열 usingL

Acroavdoc.open("Filepath","Temperory title") 

Acroavdoc.FindText("String"). 

검색 . 이제 Acroavpageview.GetPageNum()을 사용하여 현재 페이지 번호를 가져옵니다.

Dim AcroXAVDoc As CAcroAVDoc 
Dim Acroavpage As AcroAVPageView 
Dim AcroXApp As CAcroApp 

AcroXAVDoc = CType(CreateObject("AcroExch.AVDoc"), Acrobat.CAcroAVDoc) 
AcroXApp = CType(CreateObject("AcroExch.App"), Acrobat.CAcroApp) 
AcroXAVDoc.Open(TextBox1.Text, "Original document") 
AcroXAVDoc.FindText("String is to searched", True, True, False) 
Acroavpage = AcroXAVDoc.GetAVPageView() 

Dim x As Integer = Acroavpage.GetPageNum 
MsgBox("the string found in page number" & x) 
관련 문제