Skip to content

Commit f56caf6

Browse files
authored
Fix page count check (#63)
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.
1 parent e5ea0fa commit f56caf6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/PDFDoc.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ public function sign_document($certfile, $password = null, $page_to_appear = 0,
11151115
if ($imagesize === false) {
11161116
return p_warning("failed to open the image $image");
11171117
}
1118-
if (($page_to_appear < 0) || ($page_to_appear > $this->get_page_count())) {
1118+
if (($page_to_appear < 0) || ($page_to_appear > $this->get_page_count() - 1)) {
11191119
return p_error("invalid page number");
11201120
}
11211121
$pagesize = $this->get_page_size($page_to_appear);

0 commit comments

Comments
 (0)