ITADN

PdfReader.pages silently drops pages since 6.9.0

#3711OpenBenjaminBonvalet 创建于 2026-04-01
Since 6.9.0, PdfReader.pages can silently return fewer pages than the PDF actually contains. No warning or exception is raised. The affected PDF opens correctly in all viewers, and other parsers (e.g. pypdfium2) report the correct page count. # Bisect The regression bisects to #3677 ("Batch-parse all objects in ObjStm on first access"). Reverting to 6.8.x restores the correct page count. # Impact - PdfReader.pages returns N-1 pages for an N-page PDF with no warning or exception - Any code iterating reader.pages silently produces output missing that page (image extraction, PDF rewriting, etc.) - Code comparing len(reader.pages) against another parser's count gets an IndexError # To reproduce We cannot share the exact PDF but the pattern is a valid 48-page PDF where one page (page 46, 0-indexed) is silently dropped from PdfReader.pages, which returns 47 entries instead of 48. # Expected behavior Either: - The page is included in pages (even with degraded/empty content), or - A warning is emitted with the correct page count still maintained, or - An exception is raised so the caller can decide how to handle it # Versions - pypdf 6.9.0+ affected - pypdf 6.8.x works correctly
0 条评论