+
Skip to content

Conversation

MarkLindblad
Copy link
Contributor

@MarkLindblad MarkLindblad commented Oct 23, 2024

Fixes bug that where MarkDropHeaderFooter always adds _drop to all elements, causing all elements to be dropped. This is because the parameters for MarkDropHeaderFooter.__init__ are different from MarkDropHeaderFootermark_drop_header_footer:

  def __init__(self, child: Node, top: float = 0.05, bottom: Optional[float] = None, **resource_args):
      if bottom is None:
          bottom = top
      lo = top
      hi = 1.0 - bottom
      super().__init__(child, f=MarkDropHeaderFooter.mark_drop_header_and_footer, args=[lo, hi], **resource_args)
  
  @staticmethod
  @timetrace("markHeadFoot")
  def mark_drop_header_and_footer(parent: Document, lo: float, hi: float) -> Document:
      for elem in parent.elements:
          bbox = elem.data.get("bbox")
          if (bbox is not None) and ((bbox[1] > hi) or (bbox[3] < lo)):
              elem.data["_drop"] = True  # mark for removal
      return parent

Copy link
Collaborator

@alexaryn alexaryn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@MarkLindblad MarkLindblad merged commit 1a613aa into main Oct 23, 2024
12 of 13 checks passed
@MarkLindblad MarkLindblad deleted the fix-mark-preset branch October 23, 2024 23:08
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

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载