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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user