Skip to content

Commit

Permalink
Update tasks/planned_changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Apr 15, 2023
1 parent d154911 commit ef7cd16
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/devel/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Also see the issues panel and inline `TODO`/`FIXME` marks in source code.
### Main Code
* Add a matrix-based rendering method, and perhaps a support method around it for common transformations (crop, margins, rotate, mirror, ...).
* Add helpers for interruptible rendering.
* Consider adding a page object index property backed by a view of released pages on document level (`list[None | weakref.ReferenceType[PdfPage]]`) that is updated on page order changes, despite a certain risk that the page view might not match the actual state if changes are not tracked properly. (To implement this safely, PDFium would need to provide a page indexing function natively)

### Setup Infrastructure
* craft_packages: add means to skip platforms for which artefacts are missing.
Expand Down
8 changes: 6 additions & 2 deletions docs/source/planned_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ You may search for `TODO(v5)` to find the code spots in question.
```

The following API breaking changes are in consideration for the next major release:
- `PdfDocument.get_toc()` / `PdfOutlineItem`: The parameters `is_closed` (bool) and `n_kids` (abs int)
will be replaced by `count` (int), where the state corresponds to the value's sign.

- The `PdfDocument.get_toc()` / `PdfOutlineItem` API will be changed.
* The parameters `is_closed` (bool) and `n_kids` (abs int) will be replaced by `count` (int),
where the state corresponds to the value's sign.
* Instead of loading bookmark info into namedtuples in a predefined fashion, a wrapper
around the raw pdfium object with on-demand properties shall be returned.
1 change: 0 additions & 1 deletion src/pypdfium2/_helpers/_internal/bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ 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
7 changes: 6 additions & 1 deletion src/pypdfium2/_helpers/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def init_forms(self, config=None):
self.formenv = PdfFormEnv(raw, config, self)


# ?TODO(v5) consider cached property
def get_formtype(self):
"""
Returns:
Expand All @@ -172,6 +173,7 @@ def get_formtype(self):
return pdfium_c.FPDF_GetFormType(self)


# ?TODO(v5) consider cached property
def get_pagemode(self):
"""
Returns:
Expand All @@ -180,6 +182,7 @@ def get_pagemode(self):
return pdfium_c.FPDFDoc_GetPageMode(self)


# ?TODO(v5) consider cached property
def is_tagged(self):
"""
Returns:
Expand Down Expand Up @@ -466,6 +469,7 @@ def page_as_xobject(self, index, dest_pdf):
)


# TODO(v5) consider switching to a wrapper around the raw bookmark with on-demand cached properties
def _get_bookmark(self, bookmark, level):

n_bytes = pdfium_c.FPDFBookmark_GetTitle(bookmark, None, 0)
Expand All @@ -474,7 +478,6 @@ def _get_bookmark(self, bookmark, level):
title = buffer.raw[:n_bytes-2].decode('utf-16-le')

# TODO(v5) just expose count as-is rather than using two variables and doing extra work
# it's also more obvious if the number's sign just corresponds to the state (- closed, + open), rather than the current inversion with is_closed
count = pdfium_c.FPDFBookmark_GetCount(bookmark)
is_closed = True if count < 0 else None if count == 0 else False
n_kids = abs(count)
Expand All @@ -500,6 +503,7 @@ def _get_bookmark(self, bookmark, level):
)


# TODO(v5) change outline API (see above)
def get_toc(
self,
max_depth = 15,
Expand Down Expand Up @@ -724,6 +728,7 @@ def _open_pdf(input_data, password, autoclose):
return pdf, to_hold, to_close


# TODO(v5) change outline API (see above)
PdfOutlineItem = namedtuple("PdfOutlineItem", "level title is_closed n_kids page_index view_mode view_pos")
"""
Bookmark information.
Expand Down

0 comments on commit ef7cd16

Please sign in to comment.