Skip to content

Commit

Permalink
Improve comments on page object insert/remove
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Apr 4, 2023
1 parent f4eb3c7 commit 3099498
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/pypdfium2/_helpers/_internal/bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def _close_template(close_func, raw, uuid, parent, *args, **kwargs):


def close(self):
# TODO? issue a warning if needs_free=False ?
if (self.raw is None):
logger.warning(f"Duplicate close call suppressed on {self}.")
return
Expand Down
4 changes: 2 additions & 2 deletions src/pypdfium2/_helpers/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ def insert_obj(self, pageobj):
if pageobj.pdf and (pageobj.pdf is not self.pdf):
raise ValueError("The pageobject you attempted to insert belongs to a different PDF.")

# If PDFium's API allowed inserting a page object into multiple pages, our support model would need to be changed accordingly
pdfium_c.FPDFPage_InsertObject(self, pageobj)
pageobj._detach_finalizer()
pageobj.page = self
Expand All @@ -218,7 +217,8 @@ def insert_obj(self, pageobj):
def remove_obj(self, pageobj):
"""
Remove a page object from the page.
The page object must not be used afterwards, except for its ``close()`` method.
As of PDFium 5692, detached page objects may be only re-inserted into existing pages of the same document.
If the page object is not re-inserted into a page, its ``close()`` method may be called.
Parameters:
pageobj (PdfObject): The page object to remove.
Expand Down

0 comments on commit 3099498

Please sign in to comment.