Hello Nayyer,
I have gone through all above articles as reference of my functionality but i am still stuck with main logic part. According to above articles it will find particular keyword from pdf and it will also find on which page it exists. but at the time of splitting it gives only that page on which it exists. Let me explain you my requirement. e.g. if “Test” keyword exist on 1st page and then it directly exists on 5th page of pdf document. on page no 2,3,4 there is no keyword “Test” exists. so i need to split all 4 pages( page no 1,2,3,4) into one pdf. so in short i need to keep splitting all the pages into different pdf until it finds another occurrence of that keyword. it must be some inner or extra logic i need to write in following part but i am not exactly getting how can i achieve it.
//open document
Document pdfDocument = new Document(“F:/Delimiter.pdf”);
//TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“Sample”);
//TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(@"[\S]+", new TextSearchOptions(true));
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“Loan”, new TextSearchOptions(true));
//accept the absorber for all the pages
pdfDocument.Pages[1].Accept(textFragmentAbsorber);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
//loop through the fragments
//Save the page as PDF file
Document newDocument = new Document();
foreach (TextFragment textFragment in textFragmentCollection)
{
//In this loop i need to write some logic which i am not getting how to do that
//Get particular page
Page pdfPage = pdfDocument.Pages[textFragment.Page.Number];
newDocument.Pages.Add(pdfPage);
newDocument.Save(“output.pdf”);
}
any help would be highly appriciated.
Thanks & Regards
Ashish Rajguru