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 check if PDF was changed since last signed #81

Open
krupong opened this issue Aug 28, 2024 · 3 comments
Open

Option to check if PDF was changed since last signed #81

krupong opened this issue Aug 28, 2024 · 3 comments

Comments

@krupong
Copy link
Contributor

krupong commented Aug 28, 2024

How can I check pdf has not changed since last signed.

Please help !

Thanks !

@dealfonso
Copy link
Owner

Once the document has been signed, you can try to use the function get_revision and (maybe) function compare.

Taking doc A (original) and doc B (unknown), you can check if doc B is only 1 revision ahead of doc A, and the compare function only raises differences related to the nodes that are expected to change; probably the document is the same.

If you are using well-known products to sign documents (e.g., acrobat, autofirma, or others that you may know), you can check the signature structure of each of them to compare the differences and guess whether the doc has been modified or not (according to the changes are the expected or not).

Please, make a PR if you complete that task.

@dealfonso
Copy link
Owner

hi,
have you tried to make the verification?

@krupong
Copy link
Contributor Author

krupong commented Nov 30, 2024

Sorry,
I haven't tried yet.
To solve my problem, I count "%%EOF" compare with get_signature_count().

Something like this.

            $obj = PDFDoc::from_string(file_get_contents($file));
            preg_match_all("/%%EOF/", $content, $matches);
            $count = sizeof($matches[0]);
            
            $sigCount = $obj->get_signature_count();
            if ($count == $sigCount + 1) {
                $result = True; 
           } else {
               $result = False;
           }

It's works for me,but it hasn't been tested enough to make PR.
Thank you.

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

2 participants