Refactor ComposeSignaturePreviewPng to return Stream

Updated the `ComposeSignaturePreviewPng` method in the `IPdfPageImageRenderer` interface to return a `Stream` instead of a `byte[]` for improved memory efficiency when handling large image data.

- Added `ComposeSignaturePreviewPngBytes` extension method to convert the `Stream` to a `byte[]` for backward compatibility.
- Updated `PdfPageImageRenderer` to return a `Stream` and adjusted its internal logic to reset the `MemoryStream` position before returning.
- Modified `DevSignatureInkController` to use the `Stream`-based implementation for HTTP responses.
- Made minor formatting adjustments in `PdfPageImageRenderer`.

These changes optimize memory usage while maintaining compatibility with existing workflows that require `byte[]`.
This commit is contained in:
2026-10-19 14:49:48 +02:00
parent 31bf64a6f2
commit f1c8e223dd
3 changed files with 21 additions and 8 deletions

View File

@@ -90,8 +90,8 @@ public class DevSignatureInkController(
if (!renderer.IsSupportedImageFormat(element.Ink!))
return StatusCode(StatusCodes.Status415UnsupportedMediaType);
var composedBytes = renderer.ComposeSignaturePreviewPng(element);
return File(composedBytes, "image/png", $"signature-composed-{id}.png");
var composedStream = renderer.ComposeSignaturePreviewPng(element);
return File(composedStream, "image/png", $"signature-composed-{id}.png");
}
private bool IsEndpointEnabled()