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

AnnotationBuilder.rectangle() does not create a bordered rectangle #1649

Open
musman920 opened this issue Feb 21, 2023 · 2 comments
Open

AnnotationBuilder.rectangle() does not create a bordered rectangle #1649

musman920 opened this issue Feb 21, 2023 · 2 comments
Labels
workflow-annotation Everything about annotating PDF files

Comments

@musman920
Copy link

When trying to create a rectangle on pdf, there is no box displayed.
If the argument interiour_color is passed, then the rectangle is displayed.
How to create just a bordered rectangle as displayed in
https://pypdf.readthedocs.io/en/stable/user/adding-pdf-annotations.html#rectangle

Environment

Code + PDF

This is a minimal, complete example that shows the issue:

annotation = AnnotationBuilder.rectangle(
                # array of four integers [xLL, yLL, xUR, yUR] specifying the clickable rectangular area
                # add LowerLeft to UpperRight to maintain width and height
                rect=(42, 42, (510 + 42), (340 + 42)),
                # interiour_color="#bcceeb",
            )

samplerectangle.pdf

@pubpub-zz
Copy link
Collaborator

I did the test and the color not being present seems to be interpreted as transparent at least in Acrobat Reader and PDF.js
I can see it if I add :
annotation[pypdf.generic.NameObject("/C")] = pypdf.generic.ArrayObject([pypdf.generic.FloatObject(1.0),pypdf.generic.FloatObject(0.0),pypdf.generic.FloatObject(0.0)])

@MartinThoma can you confirm the behavior. Shouldn't it be a good idea to add params to pass the border color and/or a variable to set the default color?

@MartinThoma
Copy link
Member

add params to pass the border color

We can do that 👍

I think for all annotations we should make all new arguments keyword-only. It's very likely that we will add quite a bunch of parameters and I don't want to have (a) a very inconsistent order or (b) do weird hacks around ordering.

@MartinThoma MartinThoma added the workflow-annotation Everything about annotating PDF files label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workflow-annotation Everything about annotating PDF files
Projects
None yet
Development

No branches or pull requests

3 participants