We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Replace a FormField with an Image

Hi,

How can I replace a Formfield with a image.

Thank you,

JP

Hello

Thanks for your request. In your case, you can try using the following code:

// Create document and DocumentBuidler object

Document doc = new Document("C:\\Temp\\in.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

Node[] formFields = doc.GetChildNodes(NodeType.FormField, true, false).ToArray();

foreach (FormField formField in formFields)

{

builder.MoveTo(formField.ParentNode);

builder.InsertImage("C:\\Temp\\test.jpg");

}

doc.Range.FormFields.Clear();

doc.Save("C:\\Temp\\out.doc");

Best regards,

Hi Andrey, thank you for you FAST help. I'm currently implementing Aspose.Words to replace Word automation, and I have only two words to define your product: SIMPLY GREAT. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

No more automation errors, very fast creation of documents. A must have product. Thanks to your guidance, I changed my code to:

Dim Word as New Document("c:\image.doc")

Dim builder As New DocumentBuilder(Word)

Dim documentFormFields As Aspose.Words.Fields.FormFieldCollection = Word.Range.FormFields

Dim formField1 As Aspose.Words.Fields.FormField = documentFormFields("Pic1")

builder.MoveTo(formField1.ParentNode)

builder.InsertImage(Image1.Image)

Word.Range.FormFields.Clear()

Word.Save("C:\Temp\out.doc")

Thank you,

JP

Hello

Thank you very much for the kind words.

Please let us know in case of any issues, We will be glad to help you.

Best regards,