user874966
user874966

Reputation:

How to read all pages from PDF?

I am using an sdk from pdftron,which reads a single page at a time. My code would be:

PDFDoc doc = new PDFDoc(input_path);
doc.InitSecurityHandler();
PageIterator itr = doc.GetPage(1);

for (line = txt.GetFirstLine(); line.IsValid(); line = line.GetNextLine()){
  for (word = line.GetFirstWord(); word.IsValid(); word = word.GetNextWord()){
    Console.WriteLine(word.GetString());
  }
}

I want to read each and every page, I had posted my same problem in PDFTRON forums.But couldn't get the solution for this. Is it possible to read each and every pages?

Upvotes: 0

Views: 362

Answers (1)

Master Stroke
Master Stroke

Reputation: 5128

Yes,you can read each and every pages of pdf at a time.You need to do just s slight change initializing page iterator. I have modified the code,and it works fine.

    PDFDoc doc = new PDFDoc(input_path);
    doc.InitSecurityHandler();
     PageIterator itr = doc.GetPageIterator();
     for (; itr.HasNext(); itr.Next()) //  Read every page
    {
    for (line = txt.GetFirstLine(); line.IsValid(); line = line.GetNextLine())
    {
    for (word = line.GetFirstWord(); word.IsValid(); word = word.GetNextWord())
    {
    Console.WriteLine(word.GetString());
    }
    }
    }

Hope this will help you.

Upvotes: 1

Related Questions