We have noticed an issue in versions 9.6 through 10.8 of Aspose.Words for .NET (we have yet to test 11.1) where unmerged DATE fields are ‘parsed and expanded’ into multiple Run nodes during a call to MailMerge.Execute(string[], object[]).
The documents involved do contain many other merge fields that are successfully filled by the MailMerge.Execute call. Only the unmerged fields are affected. It is unclear currently whether the behavior is only exhibited in DATE fields or any field type.
This behavior is undesirable for us, since we have need in certain circumstances to programmatically replace the date value with a customized date.
Any assistance or guidance on the issue is much appreciated.
In an attempt to illustrate what I’m describing, before the MailMerge.Execute(string[], object[]) call the field’s paragraph tree looks like:
FieldStart
Run (DATE field format)
FieldSeparator
Run (complete date field value, ‘11/11/11 10:10:10 AM’)
FieldEnd
After MailMerge.Execute, it looks something like:
FieldStart
Run (DATE field format)
FieldSeparator
Run (‘11’)
Run (‘/’)
Run (‘11’)
Run (‘/’)
Run (‘11’)
Run (‘ ‘)
Run (‘10’)
Run (‘:’)
Run (‘10’)
Run (‘:’)
Run (‘10’)
Run (‘ ’)
Run (‘AM’)
FieldEnd
Hi Michael,
Thanks for your inquiry.
While using the latest version of Aspose.Words i.e. 11.1.0, I managed to reproduce this issue on my side. I have passed your concern to our development team. As soon as, any information is shared by them, I will be more then happy to share that with you.
Best Regards,
Hi,
It is to update you that I have logged this issue in our bug tracking system. Your request has been linked to the appropriate issue. Your issue ID is WORDSNET-5993. You will be notified as soon as it is resolved. Sorry for the inconvenience.
Moreover, as a temporary workaround, I would suggest you please use Document.JoinRunsWithSameFormatting method in the end once the mail merge operation is executed. For more information, please see the following link:
https://reference.aspose.com/words/net/aspose.words/document/joinrunswithsameformatting/
I hope, this will help.
Best Regards,
Awais,
Thanks so much for the prompt response.
Unfortunately, the work around did not resolve the problem. Were you able to confirm it worked in your tests?
If so, could you please share your technique. Maybe there’s something we’re missing.
Thanks…
Hi
Michael,
Thanks for your inquiry. First of all, please note that DocumentExplorer is a very useful tool which easily enables us to see the entire document structure. You can find DocumentExplorer in the folder where you installed Aspose.Words e.g. C:\Program Files (x86)\Aspose\Aspose.Words for .NET\Demos\CSharp\DocumentExplorer\bin\DocumentExplorer.exe. You can view the structure of documents by opening them with DocumentExplorer.
Secondly, I have attached three different Word documents here for your reference. There is a Date field in ‘In_Date.docx’. The following code snippet will introduce the problem in ‘Out_Date.docx’. You can verify by opening it with DocumentExplorer.
Document doc = new Document(@"c:\test\In_Date.docx");
doc.UpdateFields();
doc.Save(@"c:\test\Out_Date.docx");
Now, the following code snippet is a work around for this issue:
Document doc = new Document(@"c:\test\Out_Date.docx");
doc.JoinRunsWithSameFormatting();
doc.Save(@"c:\test\Out_Fixed.docx");
The problem is solved in Out_Fixed.docx.
Please let me know if I can be of any further assistance.
Best Regards,
Awais,
Thanks again for the prompt response.
I’ve explored the issue further and confirmed the that the JoinRunsWithSameFormatting() works as you described.
It does not work, though, for date merge fields held within a Word Table.
If you could confirm, we’d appreciate it.
Thanks…
Hi
Michael,
Thanks for your feedback. Could you please attach your input Word document you’re getting problem with here for testing? I will investigate the issue further on my side and provide you more information.
Best Regards,
Thanks, Awais. Should have thought of that.
Attached is an example of one of our simple cover pages, where the date merge field is in a Table.
Let me know if you need more…
Hi
Michael,
Thanks for your inquiry. Strangely, I was unable to reproduce this issue with ‘Enterprise Cover Page.doc’ on my side. In order to reproduce this issue on my side, could you please share your code along with the output Word document here for testing? I will investigate the issue further and provide you more information.
Best Regards,
Attached you’ll find a problem reduction of the issue.
The Zip contains a VS2010 solution w/ test code, example cover pages and unit tests that show success and failure paths for three different cover pages. Test code contains Aspose.Words v11.1.0.
NextGenCoverPage
- Does not have DATE merge fields in a Table - Fails w/o Join
- Succeeds w/ Join
Enterprise and Location Cover pages
- Have DATE merge fields within a Table - Fail w/ or w/o Join statement
- Exploring the resulting FieldStarts[3] collection post Join reveals the expansion
Thanks for your continued assistance w/ this issue…
Hi
Michael,
Thanks for the additional information.
First of all, please note that, the Date field does not split into multiple Run nodes during converting your documents to DOC format. I think, the problem occurs only when you save your documents to DOCX/DOCM, DOTX, DOTM or FlatOpc file formats.
Secondly, yes, you’re right, ‘JoinRunsWithSameFormatting’ does not seem to be working in your case when the Date field is placed inside a Table. I have logged another issue in our bug tracking system as WORDSNET-6042. Your request has been
linked to this issue and you will
be notified as soon as it is resolved.
Sorry for the inconvenience.
Best Regards,
The issues you have found earlier (filed as WORDSNET-5993;WORDSNET-6042) have been fixed in this .NET update and this Java update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.