pymupdf / PyMuPDF-Utilities

Demos, examples and utilities using PyMuPDF
GNU Affero General Public License v3.0
566 stars 153 forks source link

Chaining methods Document(filename) and load_page(page_id) fail with ValueError #18

Closed jrom99 closed 3 years ago

jrom99 commented 3 years ago

I want to get the first page in a single statement, as in:

>>>import fitz
>>>from pathlib import Path
>>>
>>>infile = Path("./some_document.pdf")
>>>page = fitz.Document(infile).load_page(0)
# raises ValueError: orphaned object: parent is None

My configuration: python version: 3.9.5, mypupdf installed with pip

fitz.__doc__ PyMuPDF 1.18.16: Python bindings for the MuPDF 1.18.0 library. Version date: 2021-08-05 00:00:01. Built for Python 3.9 on linux (64-bit).

JorjMcKie commented 3 years ago

This is intended: a feature , not a bug. Please read the chapter "Ensuring Consistency of Important Objects in PyMuPDF" of the documentation.