![how to find word in pdf how to find word in pdf](https://static.icecreamapps.com/images/howto/how-to-search-for-a-word-in-a-pdf.png)
Once you have your Page object, call its extractText() method to return a string of the page’s text ❸. To get the first page of this document, you would want to call pdfReader.getPage(0), not getPage(42) or getPage(1).
![how to find word in pdf how to find word in pdf](https://i.pinimg.com/originals/a3/7d/20/a37d2095bb42383e06fb69a5f35d14fb.png)
HOW TO FIND WORD IN PDF PDF
For example, say your PDF is a three-page excerpt from a longer report, and its pages are numbered 42, 43, and 44. This is always the case, even if pages are numbered differently within the document. PyPDF2 uses a zero-based index for getting pages: The first page is page 0, the second is Introduction, and so on. You can get a Page object by calling the getPage() method ❷ on a PdfFileReader object and passing it the page number of the page you’re interested in-in our case, 0. To extract text from a page, you need to get a Page object, which represents a single page of a PDF, from a PdfFileReader object. The example PDF has 19 pages, but let’s extract text from only the first page. The total number of pages in the document is stored in the numPages attribute of a PdfFileReader object ❶. Store this PdfFileReader object in pdfReader. To get a PdfFileReader object that represents this PDF, call PyPDF2.PdfFileReader() and pass it pdfFileObj. Then open meetingminutes.pdf in read binary mode and store it in pdfFileObj.
![how to find word in pdf how to find word in pdf](https://images.wondershare.com/pdfelement/pdfelement/7-guide/find-text.jpg)
BOARD of ELEMENTARY and SECONDARY EDUCATION 'įirst, import the PyPDF2 module. \n The Board of Elementary and Secondary Education shall provide leadershipĪnd create policies for education that expand opportunities for children,Įmpower families and communities, and advance Louisiana in an increasinglyĬompetitive global market. 'OOFFFFIICCIIAALL BBOOAARRDD MMIINNUUTTEESS Meeting of March 7, 2015 > pdfReader = PyPDF2.PdfFileReader(pdfFileObj) > pdfFileObj = open('meetingminutes.pdf', 'rb') Figure 13-1. The PDF page that we will be extracting text fromĭownload this PDF from, and enter the following into the interactive shell: