Skip to content

Commit

Permalink
Fix page count check (#63)
Browse files Browse the repository at this point in the history
Parameter $page_to_appear is zero based. The get_page_count method returns the number of pages starting with 1. The if statement does not trigger an error if 1 is provided on a document with 1 page. Reducing the count by 1 solves the issue.
  • Loading branch information
mikocevar committed Mar 20, 2024
1 parent e5ea0fa commit f56caf6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/PDFDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ public function sign_document($certfile, $password = null, $page_to_appear = 0,
if ($imagesize === false) {
return p_warning("failed to open the image $image");
}
if (($page_to_appear < 0) || ($page_to_appear > $this->get_page_count())) {
if (($page_to_appear < 0) || ($page_to_appear > $this->get_page_count() - 1)) {
return p_error("invalid page number");
}
$pagesize = $this->get_page_size($page_to_appear);
Expand Down

0 comments on commit f56caf6

Please sign in to comment.