Closed mara004 closed 1 year ago
I've made a patch that should fix this in pypdfium2 sooner or later (https://github.com/pypdfium2-team/pypdfium2/pull/224).
Thanks for this, and apologies for not responding earlier.
I'm glad that you've fixed the problem, sounds like a useful improvement too.
No problem, take your time. Sorry for the embarrassing commit repetition above, I shouldn't force push so much. 🙈
With pypdfium2, the API contract is that parent objects must not be closed before child objects are closed, i.e. order matters.
If you close the document explicitly but let pages be closed automatically on garbage collection, the document is likely to be closed before all pages are closed, which is illegal and will result in warnings.
See also https://pypdfium2.readthedocs.io/en/latest/python_api.html#memory-management. I hope to add additional clarification to the docs soon. Seeing as this is not obvious and an easy mistake to make, I guess we should update the support model to have parents keep track of children and ensure correct order automatically.
This change removes the document close calls. Alternatively, page close calls could be added.