Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to create signature appearance with a fixed name #90

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/PDFDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@ public function get_object($oid, $original_version = false) {
* @param page the page (zero based) in which the signature will appear
* @param rect the rectangle (in page-based coordinates) where the signature will appear in that page
* @param imagefilename an image file name (or an image in a buffer, with symbol '@' prepended) that will be put inside the rect
* @param string|null $name the name of the signature (if not set, a random name will be used)
*/
public function set_signature_appearance($page_to_appear = 0, $rect_to_appear = [0, 0, 0, 0], $imagefilename = null) {
public function set_signature_appearance($page_to_appear = 0, $rect_to_appear = [0, 0, 0, 0], $imagefilename = null, $name = null) {
$this->_appearance = [
"page" => $page_to_appear,
"rect" => $rect_to_appear,
"image" => $imagefilename
"image" => $imagefilename,
"name" => $name,
];
}

Expand Down Expand Up @@ -448,7 +450,7 @@ protected function _generate_signature_in_document() {
"Subtype" => "/Widget",
"FT" => "/Sig",
"V" => new PDFValueString(""),
"T" => new PDFValueString('Signature' . get_random_string()),
"T" => new PDFValueString('Signature' . $this->_appearance['name'] ?? get_random_string()),
"P" => new PDFValueReference($page_obj->get_oid()),
"Rect" => $recttoappear,
"F" => 132 // TODO: check this value
Expand Down