Generic Fields (not bookmarks or merge fields)

Currently we have automation with Word updating some "Word.Fields". one of these fields is for a signature. When a document gets "Signed" we replace the text of the field with an empty string. In the same range we insert a bitmap image of the users signature. Below are some of the key code segments of this process. Also, we do go the other way, If they "Unsign" the document we remove the image and replace the field text with "{ProviderSignature}". Could you provide example of how to accomplish this with Aspose.Word? Please keep in mind, that to say we would have to change to merge fields or bookmarks would be doable, but a major pain. As this product is currently in use by several clients and they have thousands of documents stored in database. So if possible I would like to see a way of working with the current field type.

Thanks

Creation of the signature field:
sRngText = "{ProviderSignature}"

application.ActiveWindow.View.FieldShading = Word.WdFieldShading.wdFieldShadingAlways

objWordSln.Fields.Add(Range:=objWordSln.Range, Type:=Word.WdFieldType.wdFieldEmpty, Text:="IF 0 = 0 """ & sRngText & """ """"", PreserveFormatting:=True)

objWordSln.Fields.Locked = True

Finding and inserting bitmap:
For Each objField In oTempDoc.Fields

strTextToFind = "{ProvidersSignature}"

If Not objField Is Nothing Then

If objField.Code.Text.IndexOf(strTextToFind) >= 0 Then

rngNew = objField.Result

If (Not dstResult.Tables(0).Rows(0).Item(0) Is DBNull.Value) AndAlso (CType(dstResult.Tables(0).Rows(0).Item(0), Byte()).Length > 1) Then

rngNew.Text = ""

oInLineShape = rngNew.InlineShapes.AddPicture(FileName:=m_strTempSignDocument, LinkToFile:=False, SaveWithDocument:=True)

oShape = oInLineShape.ConvertToShape()

oShape.ZOrder(MsoZOrderCmd.msoSendBehindText)

Else

rngNew.Text = CType(dstResult.Tables(1).Rows(0).Item(2), String)

End If

End If

End If

Next

Removing the bitmap image and replacing with text:
For Each objField In objWordSign.Fields

strTextToFind = "{ProvidersSignature}"

If Not objField Is Nothing Then

If objField.Code.Text.IndexOf(strTextToFind) >= 0 Then

rngNew = objField.Result

If Not IsNothing(objField.InlineShape) Then

If objField.InlineShape.Type = Word.WdInlineShapeType.wdInlineShapePicture Then

objField.InlineShape.Delete()

End If

End If

rngNew.Text = CType(dstResult.Tables(1).Rows(0).Item(1), String)

End If

End If

Next



Well, you might already know that our ultimate goal is to allow direct (or almost direct) port of any code that uses MS Word object model to Aspose.Word, but you use lots of features and in a way that Aspose.Word does not yet allow.

Basically, you have two options: modify your code and documents to use Aspose.Word as it stands now or wait for more features that allow Aspose.Word to execute most of your code almost as it stands now.

Please send me one of your documents that you process using the above code to word@aspose.com, I might be able to come up with a limited list of improvements to Aspose.Word that will allow to do what you want.