Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Sep 27, 2021 5:24 pm

I'm evaluating Spire.Doc to replace an old Word interop system. So far it has supported everything, but I've run into an issue with the mail merge processing.
I have a merge field in a .dot file that looks like this

Code: Select all
{ IF { MERGEFIELD B26STATE_CODE } = 34 "Some Text For State 34" "" }


When I run this code

Code: Select all
            cols[0] = "B26STATE_CODE";
            data[0] = "34";

            document.IsUpdateFields = true;
            document.MailMerge.Execute(cols, data);

            document.ViewSetup.DocumentViewType = DocumentViewType.PrintLayout;
            document.Document.SaveToFile("test-out.pdf", FileFormat.PDF);

            document.MailMerge.MailMergeMainDocumentType = MailMergeMainDocumentType.NotAMergeDocument;

            document.SaveToFile("test-out.doc", FileFormat.Doc);
            document.SaveToFile("test-out.docx", FileFormat.Docx);


in the PDF, I see this

Some Text For State 34


In the DOC and DOCX, I see this

{ IF 34 = 34 "Some Text For State 34" "" }


Is there something I'm missing when executing the merge?
(note: I'm setting that "NotAMergeDocument" thing because the templates sometimes have queries associated with them, and setting that makes sure that the output document doesn't have that stuff in it)

keith_ntersol
 
Posts: 3
Joined: Mon Sep 27, 2021 5:15 pm

Tue Sep 28, 2021 2:12 am

Hello Keith,

Thanks for your inquiry.
In your .doc/.docx file, you turn on the way to display field codes as follows. Please click it again, you will get the display "Some Text For State 34"
ViewFieldCodes.png



Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Sep 28, 2021 4:30 pm

Thanks, I see that is working. It matches what I see in a word produced doc.

Further comparing, I see that the INCLUDETEXT behavior is different. In the template, I have something that looks like this

Code: Select all
{ INCLUDETEXT "{ FILENAME \p }\\..\\Images\\OtherDoc.docx" \* MERGEFORMAT }


In the word produced output, the field shows the full, correct path to OtherDoc.docx, and Alt-F9 displays the embedded content. The PDF shows the embedded content.

However, in the Spire produced content, it isn't working quite right.
The doc contains the original code as shown above, and Alt-F9 hides the code but does not show the embedded content
The pdf contains this where the embedded content should be

Code: Select all
D:\projects\test\525.dot\\..\\Images\\OtherDoc.docx \* MERGEFORMAT

keith_ntersol
 
Posts: 3
Joined: Mon Sep 27, 2021 5:15 pm

Wed Sep 29, 2021 3:33 am

Hello Keith,

Thanks for your feedback.
I have noticed the issue about INCLUDETEXT field, and logged it into our issue tracking system with the ticket SPIREDOC-6751. Sorry for the inconvenience caused.
We will notify you once there is any update.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Wed Sep 29, 2021 6:09 pm

Thanks. I see that there is a similar issue with INCLUDEPICTURE. In the saved DOC, the picture works perfectly. In the PDF, no picture appears.

For reference, this is what my template is doing

Code: Select all
{ IF { INCLUDEPICTURE { IF TRUE "{ FILENAME \p }\..\Images\Entity{ MERGEFIELD IMG_NUM }.jpg" } }{ INCLUDEPICTURE { IF TRUE "{ FILENAME \p }\..\Images\Entity{ MERGEFIELD IMG_NUM }.jpg" } } }

keith_ntersol
 
Posts: 3
Joined: Mon Sep 27, 2021 5:15 pm

Thu Sep 30, 2021 3:36 am

Hello Keith,

Thanks for your further feadback.
I am sorry to say that it is a known issue. It was numbered SPIREDOC-5241 in our issue tracking system. I have urged our Dev team to fix it soon. We will inform you once it is solved.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc