Form Fields getting removed automatically

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

Hi Shirish,


Thanks for your inquiry. While testing the scenario with latest version of Aspose.Pdf for .NET, I’m unable to reproduce the issue. Please find attached resultant document for your reference. I’m afraid you are using a quite older version. Please download and try latest version of Aspose.Pdf for .NET, hopefully your issue would be resolved.

Moreover, I would like to update you that Aspose.Pdf.Kit for .NET was discontinued since 6.0.0 release and was merged in Aspose.Pdf for .NET as Aspose.Pdf.Facades namespace. So if you want to execute your old Aspose.Pdf.Kit code, you can use Aspose.Pdf.Facades namespace while using Aspose.Pdf for .NET. Please check following documentation link for migrating Aspose.Pdf.Kit to Aspose.Pdf for .NET.


Please feel free to contact us for any further assistance.

Best Regards,

May I consider this one as a bug in old dlls? we have many stuff in our application relying on Aspose and cannot upgrade as we are not sure how many things upgrade will break and need to recode. Do you have any alternative?

Hi Shirish,


As per your description, it seems to be an issue in older release versions which seem to be fixed in latest MergedAPI. We always encourage/recommend our users to latest release versions as they contain new features and resolution to issues reported in earlier release versions. Furthermore, when using this single component, you get the capability to create as well as manipulate existing PDF files.

Before upgrading your license subscription, you may test the product upgrade in trial mode and in case you encounter any issue, please feel free to contact. We will try our level best to fix any occurring issues.