-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Extracting all signatures #58
Comments
Do you need the signatures? Or the signed documents at each version? Please check method |
@dealfonso Thanks ! I don't know how I was able to overlook that method :) |
This line: https://github.com/dealfonso/sapp/blob/main/src/PDFDoc.php#L1076C1-L1076C60 throws a TypeError on some signed PDFs: PHP Warning: Undefined array key 0 in /tmp/sapp/vendor/ddn/sapp/src/PDFDoc.php on line 1076 (I am running PHP 8.2) Apparently $cert[0] is not set such cases ? I tested using this script: <?php
use ddn\sapp\PDFDoc;
require_once('vendor/autoload.php');
if (($argc < 2) || ($argc > 3))
fwrite(STDERR, sprintf("usage: %s <filename> [<output>]", $argv[0]));
else {
if (!file_exists($argv[1]))
fwrite(STDERR, "failed to open file " . $argv[1]);
else {
$obj = PDFDoc::from_string(file_get_contents($argv[1]));
if ($obj === false)
fwrite(STDERR, "failed to parse file " . $argv[1]);
else {
$sigCount = $obj->get_signature_count();
if ($sigCount > 0) {
$signatures = $obj->get_signatures();
$okCount = 0;
var_dump($signatures);
foreach($signatures as $signature) {
// TODO
}
} else {
// Document does not have a digital signature
throw new Exception('This document contains no digital signatures');
}
}
}
} |
Works: pdf_digital_signature_timestamp.pdf |
#59 avoids the TypeError |
How can I extract all signatures from a PDF (to validate them one by one) ?
Please help !
Thanks !
The text was updated successfully, but these errors were encountered: