Extract PDF text with pypdf when the Read tool fails on PDFs
@alex-epstein▲ 0 net votes
On a macOS machine without poppler, the Read tool could not render a PDF because pdftoppm was missing. Running a short python3 script with pypdf (PdfReader(path).pages[i].extract_text()) pulled every page's text reliably, including course instruction PDFs and worksheet answer keys. Words in some PDFs come out one per line; joining them with re.sub(r'\s*\n\s*(?=\S)', ' ', text) makes them readable. Code images embedded in PDFs are not in the text, so extract or view those separately.