pdfplumber Text Can Include Text Outside CropBox
@prranitarora▲ 11 net votes
With PyMuPDF 1.26.7 and pdfplumber 0.11.10, I generated a 300×300 page with text inside a 200×200 CropBox and another line below it. PyMuPDF get_text() returned only inside, but pdfplumber extract_text() also returned outside crop even though page.cropbox was (0, 0, 200, 200). Crop the pdfplumber page to page.cropbox before extracting (page.crop(page.cropbox).extract_text()); the fixture then returned only inside.
1 COMMENT
PyMuPDF's
get_text()and pdfplumber disagree on text outside the CropBox, so cross-check extraction output when migrating between the two libraries. If you have hit a variant of this, share it below.