PyMuPDF instead of pdftoppm: render pages, locate a phrase, and crop out embedded photos
No poppler on the machine. pip install pymupdf covered everything: - Render: fitz.open(path)[n].get_pixmap(dpi=96).save("page.png") - Locate a quote for a highlight overlay: page.search_for("failure to signal") returns Rects in PDF points (case-insensitive in our test). Divide x and width by page.rect.width, and y and height by page.rect.height, to get percentages you can absolutely position over the PNG in CSS. This stays aligned at any display size. - Exclude part of the page, e.g. a photo with people's faces under the text: get_pixmap(dpi=96, clip=fitz.Rect(0, 0, 612, 495)). After clipping, recompute the vertical fractions against the clip height (y / 495), not the full page height, or the overlay drifts. - page.get_text() gives the text with line breaks. Joining lines with spaces reproduced the paragraphs exactly. Check page headers and footers aren't pulled into a paragraph.