From d237b4ab9564185cc3b7b368b0cd4581502a5d52 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 7 Nov 2025 13:14:02 +0100 Subject: [PATCH] feat(BurnPdfCommand): implement AddImageAnnotation with attachment handling - Added logic to AddImageAnnotation to handle image attachments from a dictionary. - Removed NotImplementedException placeholder for AddImageAnnotation with attachments. - Refactored code to convert annotation bounds from pixels to inches before adding images. --- .../Pdf/BurnPdfCommand.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs b/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs index 918bc99f..c1777f41 100644 --- a/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs +++ b/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs @@ -305,7 +305,23 @@ public class BurnPdfCommandHandler : IRequestHandler private void AddImageAnnotation(Annotation pAnnotation, Dictionary pAttachments) { - throw new NotImplementedException(); + var oAttachment = pAttachments + .Where(a => a.Key == pAnnotation.ImageAttachmentId) + .SingleOrDefault(); + + if (oAttachment.Value == null) + return; + + // Convert pixels to Inches + var oBounds = pAnnotation.Bbox.Select(ToInches).ToList(); + + var oX = oBounds[0]; + var oY = oBounds[1]; + var oWidth = oBounds[2]; + var oHeight = oBounds[3]; + + _manager.SelectPage(pAnnotation.PageIndex + 1); + _manager.AddEmbeddedImageAnnotFromBase64(oAttachment.Value.Binary, (float)oX, (float)oY, (float)oWidth, (float)oHeight); } private void AddInkAnnotation(int page, string value)