androidtext-extractionmupdfcurrent-page

Extract text of the current page from a pdf (using MuPDF)


I have written the code to extract text from a pdf and it works fine. The problem is that the text of only the first page is getting extracted even though I am on a different page.

Here is the code that I am using -

public void extracttext()
{
TextWord[][] textWord = core.textLines(mDocView.getDisplayedViewIndex());
 int z, j;

for (z = 0; z < textWord.length; z++) {
    for (j = 0; j < textWord[z].length; j++) {
        word = word + textWord[z][j].w + " ";
    }
  }
}

What mistake am I making?


Solution

  • Well,I was making a very silly mistake. I forgot to re-initialise word to "" . So,the text that was extracted was added after the already extracted text and I used to think that text was extracted only from the first page.