Text extraction and page counting