added check for number of pages in pdf file