> For the complete documentation index, see [llms.txt](https://lauradang.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lauradang.gitbook.io/notes/web/web-scraping/read-pdfs.md).

# Read PDFs

### Extracting text

```python
import PyPDF2

pdfFile = open('file.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFile)
pageObj = pdfReader.getPage(i)
page = pageObj.extractText()
```

### Number of pages

```python
page_num = pdfReader.getNumPages()
```
