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.

Wed Mar 02, 2022 7:28 am

Hello,

I am trying to add the Free 3 of 9 Extended font into a MergeField during the mail merge, but it is lost after the Mail Merge function (The font reverts to the document default). Are there any known solutions or would I have to implement your Spire.Barcode product into our solution?

Kind regards,

Adrian

adrianchan
 
Posts: 13
Joined: Fri Dec 10, 2021 2:08 am

Wed Mar 02, 2022 8:17 am

Hello,

Thanks for your inquiry!

I simulated a DOCX file with a merge field use "Free 3 of 9 Extended" font, and merge it with our latest Spire.Doc for net Version:10.2.11, but did not reproduce your issue, the font is correct. If you are not using the latest version, I just recommend that you can try it first. If the issue still exists, please provide us with your input file for further investigate. Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Thu Mar 03, 2022 12:47 pm

Hi Marcia,

We are using FreeSpire.Doc if that changes anything and the method to insert the data into the barcode is via the public void Execute(DataTable table) method.

Kind regards,

Adrian

adrianchan
 
Posts: 13
Joined: Fri Dec 10, 2021 2:08 am

Fri Mar 04, 2022 6:16 am

Hello Adrian,

Thanks for your feedback!

I tried to mail merge again use Execute(DataTable table) method with our latest Free Spire.Doc for .NET Version:10.2, but still cannot reproduce your issue. Here I attached my input file and testing code for your reference.
Code: Select all
            Document document = new Document();
            document.LoadFromFile("Before.docx");
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add(new DataColumn("UseSpecificFont"));
            dataTable.Rows.Add(new string[] { "1234567" });
            document.MailMerge.Execute(dataTable);
            document.SaveToFile("res.docx");

To help us better investigate in your issue, please provide us with your input file. Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Fri Mar 04, 2022 7:24 am

Hi Marcia,

Attached is my input file. Looking at your MergeField, I noticed some differences such as the font not extending to the MergeField (images in the zip file for your reference) so maybe it's a word formatting issue though I'm not completely sure.

Kind regards,

Adrian

adrianchan
 
Posts: 13
Joined: Fri Dec 10, 2021 2:08 am

Fri Mar 04, 2022 8:08 am

Hello Adrian,

Thanks for sharing more information!

After further investigate, I found that even mail merge your file with MS Word, the "BARCODE" field cannot in the "Free 3 of 9 Extended" font. Kindly note that our Spire.Doc is following the MS Word standard, if the MS Word does not apply the font, our product cannot too.

You can consider setting the font of the "BARCODE" field before mail merge by referring to the following code. After setting font, the result is in "Free 3 of 9 Extended" font.
Code: Select all
            Document document = new Document();
            document.LoadFromFile(@"E:\testdoc\barcodefile\barcode_input_file.docx");

            foreach(Field field in document.Fields)
            {
                if(field.Type == FieldType.FieldMergeField)
                {
                    MergeField mergeField = field as MergeField;
                    if (mergeField.FieldName == "BARCODE")
                    {
                        mergeField.CharacterFormat.FontName = "Free 3 of 9 Extended";
                    }
                }
            }


            DataTable dataTable = new DataTable();
            dataTable.Columns.Add(new DataColumn("BARCODE"));
            dataTable.Rows.Add(new string[] { "1234567" });
            dataTable.Rows.Add(new string[] { "2345789" });
            dataTable.Rows.Add(new string[] { "8245920" });
            dataTable.Rows.Add(new string[] { "5047891" });
            dataTable.Rows.Add(new string[] { "4517152" });
            document.MailMerge.Execute(dataTable);
            document.SaveToFile("res.docx");



Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Fri Mar 04, 2022 11:13 am

Hi Marcia,

The issue seems to be resolved for now, many thanks!

Kind regards,

Adrian

adrianchan
 
Posts: 13
Joined: Fri Dec 10, 2021 2:08 am

Mon Mar 07, 2022 1:07 am

Hello Adrian,

Glad to hear that the issue has been solved.

If you encounter any issues related to our product in the future, just feel free to contact us.

Have a nice day!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.Doc