Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addHighlightAnnot function produces ellipses instead of rectangles #3963

Closed
wangzehao1003 opened this issue Oct 18, 2024 · 4 comments
Closed
Labels
not a bug not a bug / user error / unable to reproduce

Comments

@wangzehao1003
Copy link

Description of the bug

Why highlight annotation are not simple rectangles, but with rounded corners and both sides are curved. It looks not perfect and that interaction area have deeper colors.
bug

How to reproduce the bug

highlight_rect = fitz.Rect(x0, y0, x1, y1)
highlight = page.add_highlight_annot(highlight_rect)

### PyMuPDF version

1.24.10

### Operating system

Windows

### Python version

3.9
@JorjMcKie JorjMcKie added the not a bug not a bug / user error / unable to reproduce label Oct 18, 2024
@JorjMcKie
Copy link
Collaborator

You did not provide any reproducible data.
So, any reaction from my side inevitably contains some degree of guesswork.

That said: this is no bug!

  • Highlight annotations do not deliver rectangles but have have curved left and right edges.
  • Highlight annotations by default are created using blend mode "Multiply". This means the following:
    image

As you see, the effect you are complaining about is a result of your color choice. It will not occur when you stay with the default color.
So choose a different color or experiment with different blend modes. Refer to this folder to get an impression.

@wangzehao1003
Copy link
Author

Thanks for your reply. Is there any method that can make the highlight areas look like simple rectangles, like figure-2 I post below. Now I got figure-1 which is not satisfied.
badcase
goodcase

@JorjMcKie
Copy link
Collaborator

You can do that - but not with highlight annotations! They are what they are.
Simply use page.add_rect_annot(). Then update the annotation by setting blending mode to "Multiply" - to achieve the behavior of highlighting.

If you want to add permanent rectangles (annotations can be removed), then use page.draw_rect(..., overlay=False)`. This will put the color behind other page content.

@wangzehao1003
Copy link
Author

Now I got it by using page.add_rect_annot() with "Multiply" mode. Thanks a million.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug not a bug / user error / unable to reproduce
Projects
None yet
Development

No branches or pull requests

2 participants