Word to PDF - Complex

Need a tool to take a Word doc with Mail Merge Fields and convert to PDF with those Mail Merge Fields converted to Form Fields of the same name.
Does any of your products support this?


Thanks for your inquiry. You can achieve your requirement by using Aspose.Words. Please use the following code snippet to convert Mail Merge field into text form field.

Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
foreach (string fieldname in doc.MailMerge.GetFieldNames())
    builder.InsertTextInput(fieldname, TextFormFieldType.Regular, "", fieldname, 0);
PdfSaveOptions pdfOptions = new PdfSaveOptions();
pdfOptions.PreserveFormFields = true;
doc.Save(MyDir + "Out.pdf", pdfOptions);

The MailMerge.GetFieldNames Method returns a collection of mail merge field names available in the document. DocumentBuilder.InsertTextInput method inserts a text form field at the current position.

The PdfSaveOptions.PreserveFormFields property Specifies whether to preserve Microsoft Word form fields as form fields in PDF or convert them to text. Default is false.

Hope this helps you. Please let us know if you have any more queries.