Skip to content

Skip unreadable pages during PDF extraction instead of failing the whole book#1398

Open
NilsLeo wants to merge 1 commit into
ciromattia:masterfrom
NilsLeo:up/pdf-page-resilience
Open

Skip unreadable pages during PDF extraction instead of failing the whole book#1398
NilsLeo wants to merge 1 commit into
ciromattia:masterfrom
NilsLeo:up/pdf-page-resilience

Conversation

@NilsLeo

@NilsLeo NilsLeo commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

When PyMuPDF raises while rendering or extracting a single page, the exception propagates out of the worker Pool and often cannot be pickled (SwigPyObject), so the entire job dies with an opaque TypeError about pickling instead of the real cause. A PDF with a handful of bad pages fails completely even though every other page is fine.

This catches per-page errors inside the worker, logs a warning, skips the offending page and continues — so the book still converts, and genuine failures surface with a clear message rather than a masked pickling error.

When PyMuPDF raised while rendering or extracting a single page, the
exception propagated out of the worker Pool and often could not be pickled
(SwigPyObject), so the whole job died with an opaque pickling TypeError
instead of the real cause. Catch per-page errors, skip the offending page
and continue, so a PDF with a few bad pages still converts.
@axu2

axu2 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Do you have a small sample example PDF file for failing rendering and any other relevant examples for other PRs?

@NilsLeo

NilsLeo commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Yes, quite busy atm, but will try to provide relevant examples for each bug ie the applied settings and the file which triggered the exception

@axu2

axu2 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

I guess I'm more interested in the exact underlying error messages (sometimes kcc hides the underlying error since error handling isn't the best)

NilsLeo added a commit to NilsLeo/kcc that referenced this pull request Jul 24, 2026
Revert the render_page/extract_page per-page try/except skip so master no
longer carries the pdf-page-resilience fix (that change lives on
up/pdf-page-resilience / PR ciromattia#1398). Lets master reproduce the original
per-page PDF failure for A/B testing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants