When iterating over the Runs contained in a document, is there some way to determine if a Run contains a MailMerge field?
My end goal here is to collect some data on our library of documents that includes the mail merge fields used and page in the document it’s used on. I’m already iterating over the runs to pull out FontInfo data so this would be pretty convenient.
Hi there,
Thanks for your inquiry.
Do you mean check if a run is contained within a field? This because runs cannot contain fields, only paragraphs contain fields. Fields are made up of special nodes which appear as siblings of runs in a paragraph and wrap around the nodes contained within the field. If there is any confusion please see the structure of the Document Object Model here for details.
You can quickly find if a run is inside a field by using the SelectNodes method. You can find details and code on the second example on this API page here.
Note that this does not find runs within fields which span more over multiple paragraphs (most fields do not do this but it is possible).
Thanks,
Hi there,
Thanks for pointing that out to me. I have noticed this spelling mistake before and it has been fixed in the .NET version of the documentation which is updated on the site already.
As soon as autoporting to Java is complete I will update this page in the Java documentation as well.
Thanks,
Hi there,
Also note that sometime shortly we will be releasing the next version of the public field api. This should include a built-in method to find the field of a supplied node e.g finding the field that a Run node belongs to.
We will inform you as soon as this is ready.
Thanks,
Thanks for your request. Please expect a reply before next hotfix (within 3-4 weeks). We might just fix the problem or provide you more information.
Best regards,