Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEEP_MERGEFIELD isn't keeping the mergefield? #605

Open
Mieges opened this issue Feb 2, 2025 · 0 comments
Open

KEEP_MERGEFIELD isn't keeping the mergefield? #605

Mieges opened this issue Feb 2, 2025 · 0 comments

Comments

@Mieges
Copy link

Mieges commented Feb 2, 2025

Hello folks! :)
I have the following problem:
For example, I would like to generate a docx for an event that contains all the surnames of people on my map. This should represent a list of invited guests.
I have taken the list with the two people from the example file FieldMailMerge.java. I have a Word template with a single mail merge field called “Kundenname”.

Then I call the following:

org.docx4j.model.fields.merge.MailMerger.setMERGEFIELDInOutput(MailMerger.OutputField.KEEP_MERGEFIELD);
WordprocessingMLPackage output = org.docx4j.model.fields.merge.MailMerger.getConsolidatedResultCrude(wordPackage, data);
String outputPath = System.getProperty(“user.dir”) + “/DOCX_from_merge.docx”;
output.save(new java.io.File(outputPath) );

Now only one name of two has been inserted.
The merge field is gone and I can't make another substitution to insert another name.

The way I see it, KEEP_MERGEFIELD does not keep the mergefield, right?

Or is my choice of method not appropriate for my project and is there perhaps a better alternative to output all names of persons with a single mergefield?

I am using version 8.3.13, Windows 11, Java version: Azul Zulu 1.8.0_432.

Translated with DeepL.com (free version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant