Hi Aspose,
Background: My code had created a PDF page with information about who is signing the document. The example page M1_22.PDF file has all the required form fields to imprint the signatures of all the parties. Signatures are nothing but images placed behind the form fields (refer second file A1_22.pdf). Later form fields will be removed and only images will be there in the document. There is a front end process in my application where user clicks on button and code replaces form fields with images.
Aspose.PDF version 7.1.0.0, Aspose.PDF.Kit 6.0.0.0
Problem: When system process a user, in this example an applicant, it automatically removes the form fields with name "DATESIGNEDM01_2" at the very first call to following code.
Public Sub ReplaceImage(ByVal sFilename As String, ByVal sFieldName As String, ByVal sImageFilename As String)
Dim objLic As New Aspose.Pdf.Kit.License
objLic.SetLicense("Aspose.Total.lic")
Try
Dim sourceStream As Stream = CreateStream(sFilename)
Dim imageStream As Stream = CreateStream(sImageFilename)
Dim form As New Aspose.Pdf.Kit.Form(sourceStream)
Dim sFields() As String = form.FieldNames
If Array.IndexOf(sFields, sFieldName) <> -1 Then
Dim myFieldFacade As FormFieldFacade = form.GetFieldFacade(sFieldName)
Dim box As Drawing.Rectangle = myFieldFacade.Box
Dim msOut As New MemoryStream
Dim Mender As New PdfFileMend(sourceStream, msOut)
Mender.AddImage(imageStream, 1, box.X, box.Y, box.Right, box.Bottom)
Mender.Close()
imageStream = Nothing
Dim fsOut As New MemoryStream
fsOut = msOut
WriteStream(fsOut, sFilename)
End if
Catch ex As Exception
Throw New Exception("Exception in Replacing Image:" & ex.Message)
End Try
End Sub