Skip to content

PolyLine annotation is not visible #1805

@femtozer

Description

@femtozer

I'm trying to add a polyline annotation to a pdf file.
It does not work whether it is an existing file or a new file (add_blank_page).

Environment

Which environment were you using when you encountered the problem?

$ python -m platform
macOS-12.6.1-arm64-arm-64bit

$ python -c "import pypdf;print(pypdf.__version__)"
3.8.0

Code + PDF

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

from pypdf import PdfWriter
from pypdf.generic import AnnotationBuilder

writer = PdfWriter()
writer.add_blank_page(200, 200)

annotation = AnnotationBuilder.polyline(
    vertices=[
        (50, 50),
        (50, 150),
        (150, 150),
        (150, 50),
        (50, 50),
    ],
)
writer.add_annotation(page_number=0, annotation=annotation)

with open("output.pdf", "wb") as f:
    writer.write(f)

The output pdf file is empty: output.pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    nf-documentationNon-functional change: Documentationworkflow-annotationEverything about annotating PDF files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions