dealfonso / sapp

Simple and Agnostic PDF Document Parser in PHP - sign PDF docs using PHP
GNU Lesser General Public License v3.0
110 stars 29 forks source link

Use $page_to_appear optional parameter #62

Closed mikocevar closed 5 months ago

mikocevar commented 5 months ago

Parameter is not passed to set_signature_appearance method. This patch makes the optional parameter working.

mikocevar commented 5 months ago

@parallels999 This already exists in the same file.

if (($page_to_appear < 0) || ($page_to_appear > $this->get_page_count())) {
    return p_error("invalid page number");
}

https://github.com/dealfonso/sapp/blob/a2f755511cbc303b1a6701fdf853e50d286d8281/src/PDFDoc.php#L1118:L1120

parallels999 commented 5 months ago

Sorry, I didn't see it, my bad

mikocevar commented 5 months ago

No need to! Your suggestion is on point anyway.

Looking at the code I think there is a bug in this check. If $this->get_page_count() returns 3 (in case of 3 pages) and the $page_to_appear is zero based (as per docblock description), then there will be an error.

($page_to_appear > $this->get_page_count() - 1) would be correct. Need to confirm this and I will make another PR.

josevv28 commented 4 months ago

Great, needs a release

dealfonso commented 4 months ago

you are right... release 1.4.2. done