Is there any API available which can be used to replace variables in docx like velocity/xdocreport does? I saw the document.getVariables api but could not understand how it works. Please let me know.
Thanks for your inquiry. The Document.Variables returns the collection of variables added to a document or template. Please check the following code example for your kind reference.
Document doc = new Document(); doc.getVariables().add("Var1", "Aspose.Words"); DocumentBuilder builder = new DocumentBuilder(doc); builder.insertField("DOCVARIABLE var1"); doc.updateFields(); doc.save(MyDir + "Out.docx");
If you still face any issue, please share your input and expected output document here for our reference. We will then provide you more information about your query along with code.