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

Free Support Forum - aspose.com

How to get the text of mail merge if

I defined {IF {MERGEFIELD A}=“Yes” {MERGEFIELD A} “”}. How could get the whole text of the mail merge IF?
Thanks!

Hi Zheng,


Thanks for your inquiry. Please try executing the following code to achieve this:
for (Field f : (Iterable<Field>) doc.getRange().getFields()){
if (f.getType() == FieldType.FIELD_IF)
System.out.println(f.getStart().getParentNode().getText());
}
I hope, this helps.

Best regards,

Yes. It helps. Thank you very much!
If I have {IF {MERGEFIELD A}=“Yes” {MERGEFIELD A} “”} and some merge fields like {MERGEFEILD B}, {MERGEFIELD C} defined in a document. How could I only get the merge fields outside the mail merge IF? i.e. only get {MERGEFIELD B} and {MERGEFIELD C}, no {MERGEFIELD A}. Thanks!

Hi Zheng,


Thanks for your inquiry. I am working over your query and will get back to you the earliest possible.

Best regards,