signature: add index on PDFSignatureZone + init POST signature

This commit is contained in:
nobohan
2024-07-11 08:06:18 +02:00
parent 39d3ba2f40
commit 77da2c1ac6
7 changed files with 66 additions and 20 deletions

View File

@@ -16,6 +16,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
final readonly class PDFSignatureZone
{
public function __construct(
#[Groups(['read'])]
public int $index,
#[Groups(['read'])]
public float $x,
#[Groups(['read'])]
@@ -31,7 +33,8 @@ final readonly class PDFSignatureZone
public function equals(self $other): bool
{
return
$this->x == $other->x
$this->index == $other->index
&& $this->x == $other->x
&& $this->y == $other->y
&& $this->height == $other->height
&& $this->width == $other->width

View File

@@ -37,6 +37,7 @@ class PDFSignatureZoneParser
$defaults = $pdf->getObjectsByType('Pages');
$defaultPage = reset($defaults);
$defaultPageDetails = $defaultPage->getDetails();
$zoneIndex = 0;
foreach ($pdf->getPages() as $index => $page) {
$details = $page->getDetails();
@@ -48,7 +49,8 @@ class PDFSignatureZoneParser
foreach ($page->getDataTm() as $dataTm) {
if (str_starts_with($dataTm[1], self::ZONE_SIGNATURE_START)) {
$zones[] = new PDFSignatureZone((float) $dataTm[0][4], (float) $dataTm[0][5], $this->defaultHeight, $this->defaultWidth, $pdfPage);
$zones[] = new PDFSignatureZone((int) $zoneIndex, (float) $dataTm[0][4], (float) $dataTm[0][5], $this->defaultHeight, $this->defaultWidth, $pdfPage);
$zoneIndex++;
}
}
}