Skip to content

page labels: raise a clear error for label_start below 1 - #2067

Merged
andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:page-label-start-validation
Oct 28, 2026
Merged

andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:page-label-start-validation

Conversation

@RavSinghChandan

Copy link
Copy Markdown

FPDF.add_page() and FPDF.set_page_label() accepted any label_start and wrote it as the page label /St value, so label_start=0 or -2 produced /St 0 or /St -2. The PDF specification (ISO 32000, page label dictionary) requires St to be an integer greater than or equal to 1.

Both methods now raise ValueError: 'label_start' parameter must be equal or greater than 1: 0 before changing any state. Added test_page_label_start_below_one next to test_page_label, and noted the rule in the add_page() docstring.

@andersonhc
andersonhc merged commit f16ed08 into py-pdf:master Oct 28, 2026
23 checks passed
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