Skip to content

Commit 63cd8ea

Browse files
committed
fix: restore signature adapter compatibility
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent b616fc7 commit 63cd8ea

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
// SPDX-FileCopyrightText: 2026 LibreSign
4+
// SPDX-License-Identifier: AGPL-3.0-or-later
5+
6+
declare(strict_types=1);
7+
8+
namespace LibreSign\XObjectTemplate\Integration;
9+
10+
use LibreSign\XObjectTemplate\Dto\CompileResult;
11+
12+
final class SignatureAppearanceXObjectAdapter
13+
{
14+
/**
15+
* Output compatible with consumers expecting the historical PDF signer payload.
16+
*
17+
* @return array{
18+
* stream: string,
19+
* resources: array<string, mixed>,
20+
* bbox: array{0: float, 1: float, 2: float, 3: float}
21+
* }
22+
*/
23+
public function toPdfSignerPayload(CompileResult $result): array
24+
{
25+
return (new XObjectPayloadAdapter())->toXObjectPayload($result);
26+
}
27+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
// SPDX-FileCopyrightText: 2026 LibreSign
4+
// SPDX-License-Identifier: AGPL-3.0-or-later
5+
6+
declare(strict_types=1);
7+
8+
namespace LibreSign\XObjectTemplate\Tests\Unit\Integration;
9+
10+
use LibreSign\XObjectTemplate\Dto\CompileResult;
11+
use LibreSign\XObjectTemplate\Integration\SignatureAppearanceXObjectAdapter;
12+
use PHPUnit\Framework\TestCase;
13+
14+
final class SignatureAppearanceXObjectAdapterTest extends TestCase
15+
{
16+
public function testAdapterMapsToExpectedPayload(): void
17+
{
18+
$adapter = new SignatureAppearanceXObjectAdapter();
19+
$result = new CompileResult(
20+
contentStream: 'BT\n(Foo) Tj\nET',
21+
resources: ['Font' => ['F1' => ['BaseFont' => '/Helvetica']]],
22+
bbox: [0.0, 0.0, 240.0, 84.0],
23+
);
24+
25+
$payload = $adapter->toPdfSignerPayload($result);
26+
27+
self::assertSame('BT\n(Foo) Tj\nET', $payload['stream']);
28+
self::assertSame(['Font' => ['F1' => ['BaseFont' => '/Helvetica']]], $payload['resources']);
29+
self::assertSame([0.0, 0.0, 240.0, 84.0], $payload['bbox']);
30+
}
31+
}

0 commit comments

Comments
 (0)