Free Support Forum -

Creating Field sequences

I am creating a new docx using a cloned template docx.

templateDoc = new Document(ourTemplateDocPath);
wordClonedDocument = templateDoc.deepClone();
knownStyles = wordClonedDocument.getStyles();
currentSection = wordClonedDocument.getFirstSection();
currentBody = currentSection.getBody();

Then creating Paragraphs and Runs to form new multi-Run paragraphs.

I have to create a Field sequence to accommodative mailto and url but cannot see how this is done.
I note that using DocumentBuilder seems to allow a method but is this the only way to achieve this ?



Hi Jan,

Thanks for your inquiry. Yes, you can use the DocumentBuilder.insertField method to inserts a Word field into a document and updates the field result. Please check the following code snippet for your kind reference. Hope this helps you. Please let us know if you have any more queries.

Document doc = new

Style heading1 = doc.getStyles().get("Heading 1");

DocumentBuilder builder = new DocumentBuilder(doc);


builder.write("Level 1");



builder.write("Table ");

builder.insertField("STYLEREF \"Heading 1\" \\n");


builder.insertField("SEQ tables \\s 1");

builder.writeln(" Description of the table."); + "Out.docx");