Hello!
We are using Aspose.Words for Java (version 21.2.0) to convert doc/docx files to PDF and also to using MailMerge function to fill some predefined data in our documents. Recently our customers reached us with the problem regarding change of content during this operation. I created a sample document to reproduce this issue and have a question if this behaviour is configurable or can be disabled?
Steps to reproduce the issue are as follows:
- Create field TITLE in document (note: this is not a MERGEFIELD and shows as
{ TITLE "Title Placeholder" \* MERGEFORMAT }
- In normal editing mode manually modify the text of a placeholder to Actual Title (in mergefields view the field still shows as “Placeholder”, but in normal view it shows as our modified text)
- Add a MERGEFIELD in document (in our case it is
{ MERGEFIELD Name \* MERGEFORMAT }
- Execute some code with MailMerge functional to fill Name mergefield, ie:
Document document = new Document(SRC_PATH);
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setSaveFormat(SaveFormat.PDF);
document.getMailMerge().execute(new String[]{"Name"}, new Object[]{"John Doe"});
document.save(DST_PATH, saveOptions);
It may be done with or without converting to PDF format (doesn’t matter if I select different SaveFormat here).
Every time that MailMerge is used - our manually edited text (Actual Title) disappears in the output result - output text resets to TITLE placeholder - “Title Placeholder”.
So my question is - is there any way or option to avoid this TITLE editing (or resetting)? To just update mergefields and to not modify any other document fields?
Also, this behaviour reproduces even if document doesn’t have any mergefields (only TITLE field), or when executed “empty” MailMerge, i.e. document.getMailMerge().execute(new String[]{}, new Object[]{});
Sample document (.docx) and produced result (.pdf) by this code are attached here
sample.docx (11.3 KB)
sample_mergeFields.pdf (12.3 KB)