Using content control inside merge field condition

Hi there,
Can I use the content control text field inside the merge field condition? if yes, can you give me the example and document how to use it in Java? Many thanks!

@bkimtho Sure, you can use SDT in the IF field condition. For example see the attached documents and the following code:

Document doc = new Document("C:\\Temp\\in.docx");
doc.getMailMerge().execute(new String[] { "test" }, new String[] { "test" });
doc.save("C:\\Temp\\out.docx");

in.docx (19.2 KB)
out.docx (16.2 KB)

Thanks for your support,
I tried to export to pdf file and also want to keep the field editable after generation but I don’t know why I get the exception java.util.EmptyStackException , I don’t know if there are any limitations for it.

PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setPreserveFormFields(true);
Document document = doMailMerge(documentTemplate);
document.save("/Users/btktho/Downloads/out.pdf", saveOptions);

@bkimtho Could you please attach the problematic document here for testing? I checked the scenario with the document I have attached in my previous reply and the problem is not reproducible on my side.