I have a fillable PDF created in lifecycle designer with a few image fields on it. when I run the code the image is picked up as a PdfButtonWidgetFieldWidget, which is fine, but I can't set the image on it... I looked through the object hierarchy but could not see where to set the image on the button...
Also, I cannot use the replaceimage() method because it doesn't seem to work???
a PdfSignatureFieldWidget would work as well but again I can't set an image to that either.
I have the pdf attached.
I don't have a license yet but will in a few days if that makes any difference...
*** here's the part of the code where I get the image field object.
If TypeOf field Is Spire.Pdf.Widget.PdfButtonWidgetFieldWidget Then
' get the button/imageField
Dim button As Spire.Pdf.Widget.PdfButtonWidgetFieldWidget = CType (field,Spire.Pdf.Widget.PdfButtonWidgetFieldWidget)
If (button.Name = "TimeSheet[0].#subform[0].imgEmp[0]") Then
' get the button styles
Dim styled As Spire.Pdf.Widget.PdfStyledFieldWidget = CType(field, Spire.Pdf.Widget.PdfStyledFieldWidget)
'the buttons image dementions
Dim imgDimensions As System.Drawing.RectangleF = styled.Bounds
'employeeSignature from the database
Dim sig As Byte() = Convert.FromBase64String(result.employeeSignature)
' *** the work around - this doesn't set the image to the button, just draw it on the page where it should be.
Dim image As Spire.Pdf.Graphics.PdfImage
Try
image = Spire.Pdf.Graphics.PdfImage.FromImage(byteArrayToImage(sig))
Catch ex As Exception
End Try
Dim pageBase As Spire.Pdf.PdfPageBase = doc.Pages(0)
If Not image Is Nothing Then
pageBase.Canvas.DrawImage(image, imgDimensions)
End If
End If
End If
Private Function byteArrayToImage(ByVal imageBytes As Byte()) As System.Drawing.Image
Dim image As Bitmap = Nothing
Try
Using imageStream As MemoryStream = New MemoryStream(imageBytes, False)
image = New Bitmap(imageStream)
End Using
Catch ex As Exception
End Try
Return image
End Function