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 update existing signature box (instead of always creating a new one) #88

Open
ridgey-dev opened this issue Jan 6, 2025 · 3 comments

Comments

@ridgey-dev
Copy link

Right now the PDFDoc::_generate_signature_in_document always creates a new annotation object. I would like to have the functionality to update an existing signature box.

For now I extended the PDFDoc object, so that it does:

$annotationObject = $this->get_object($this->signatureBoxId);

instead of

PDFDoc::449
$annotation_object = $this->create_object([
                "Type" => "/Annot",
                "Subtype" => "/Widget",
                "FT" => "/Sig",
                "V" => new PDFValueString(""),
                "T" => new PDFValueString('Signature' . get_random_string()),
                "P" => new PDFValueReference($page_obj->get_oid()),
                "Rect" => $recttoappear,
                "F" => 132  // TODO: check this value
            ]
        );

I created the setSignatureBoxId(int $signatureBoxId) function to set the signature box ID that will be updated. This function checks if the given ID is an existing signature box (correct type/subtype etc.)

@angeljqv
Copy link

angeljqv commented Jan 6, 2025

Feel free to make a PR with the fix

@dealfonso
Copy link
Owner

I do not know what is your use case. Could you please tell us about it? Is it of general interest?

@ridgey-dev
Copy link
Author

ridgey-dev commented Jan 7, 2025

I do not know what is your use case. Could you please tell us about it? Is it of general interest?

The use case for this functionality is to work with documents that already contain predefined, unsigned signature boxes. These boxes are typically included in the document as placeholders to visually indicate to the end user where their signature will appear after signing.

Currently, the package automatically creates a new signature box with a random name for every signature action. This behavior leads to PDFs that contain both the newly created (signed) signature box and the original (unsigned) placeholder, which is not ideal for workflows where maintaining the integrity of pre-existing placeholders is critical.

To address this, I have created a pull request to enable the functionality of updating existing signature boxes instead of creating new ones. This enhancement ensures that the package can effectively handle documents with predefined signature placeholders without introducing redundancies. You can view the pull request here for further details: #89 Option to update existing signature box (instead of always creating a new one

I believe this improvement aligns with the needs of users working with preformatted documents and would be of general interest to those looking for a seamless signing process in such cases.

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

No branches or pull requests

3 participants