Hi, I’m evaluating Aspose.Imaging for .NET for adding signatures to tiff files stored in a database. The source document is already loaded in a Dynamsoft.ImageCore
which allows me to access a single page as a System.Drawing.Bitmap
. Unfortunately, Aspose.Imaging only supports opening files or IO streams. The signature comes from a binary field in a database and is returned as a byte array. This is not supported by Aspose.Imaging either. My code is below:
Dim original1stpagebm As System.Drawing.Bitmap = materialsfrm.m_ImageCore.ImageBuffer.GetBitmap(index)
'Load into an IO stream
Dim ms As New MemoryStream
original1stpagebm.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff)
ms.Seek(0, 0)
Dim original1stpage As Aspose.Imaging.Image = Aspose.Imaging.Image.Load(ms)
'Get signature from DB as byte array
materialsfrm.ADOCmdMiscSelects.Parameters("@p_op").Value = "GETSIG"
materialsfrm.ADOCmdMiscSelects.Parameters("@p_misc_code").Value = "abarrett"
Dim rs As SqlDataReader = materialsfrm.ADOCmdMiscSelects.ExecuteReader()
rs.Read()
Dim ContractManagerSignaturebaor() As Byte = rs("manager_signature")
Dim ContractManagerSignatureWidth As Decimal = rs("signature_width")
Dim ContractManagerSignatureHeight As Decimal = rs("signature_height")
rs.Close()
Dim signature As Aspose.Imaging.Image = Aspose.Imaging.Image.Load(New MemoryStream(ContractManagerSignaturebaor))
Dim graphics As New Aspose.Imaging.Graphics(original1stpage)
graphics.DrawImage(signature, New Aspose.Imaging.Point(original1stpage.Height - signature.Height, original1stpage.Width - signature.Width))
Dim ms2 As New MemoryStream
original1stpage.Save(ms2)
ms2.Seek(0, 0)
'Push the updated page back to the ImageCore
materialsfrm.m_ImageCore.ImageBuffer.SetBitmap(index, New Bitmap(ms2))
the resulting page does not show the signature. I know that the signature is OK since I use the very same one in another module when inserting into an Aspose.Words document as follows:
Dim image As Aspose.Words.Drawing.Shape = builder.InsertImage(ContractManagerSignaturebaor)
Luckily, Aspose.Words does accept a byte array directly.
Do you have any ideas why the signature does not get imprinted on the source image please?
Thank you very much