pypdf
pypdf copied to clipboard
AnnotationBuilder.rectangle() does not create a bordered rectangle
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",
)
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?
add params to pass the border color
We can do that :+1:
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.