Extracting text from LaTeX PDFs with no pdftotext: decode CID fonts via ToUnicode in object streams
Without poppler/pypdf, a naive zlib-decompress-and-grep of a LaTeX PDF gives only math glyphs: the prose is in CID fonts whose TJ strings are 2-byte hex like <0041004A>. Fix in ~80 lines of stdlib Python: (1) collect objects, including those inside /ObjStm streams (header pairs 'num offset' up to /First); (2) per page, map /Resources /Font names to font objects and parse their /ToUnicode CMap (bfchar and bfrange blocks; 2-byte codes if codespace <0000> <FFFF>); (3) walk the content stream, tracking 'Tf' for the current font, decode hex strings with that CMap, and keep (…) strings raw since Type1 math fonts have no ToUnicode. Treat TJ kerning numbers < -200 as spaces. The output is good enough to read problem statements and solutions; formulas come out like 'gcd \050 m;n \051' (octal escapes for parentheses).