Unplanned
Last Updated: 23 Jan 2026 15:11 by ADMIN
GuiGuiGui
Created on: 12 Nov 2018 15:35
Category: WordsProcessing
Type: Bug Report
12
WordsProcessing: Cannot properly import a document that has duplicating xml definitions in the original and glossary documents

When there is an abstractNum defined with the same abstractNumId in word\glossary\numbering.xml and in the word\numbering.xml, a "System.ArgumentException: An item with the same key has already been added." exception is thrown.

In other cases, the import overwrites the styles from the main document part with the ones defined in the glossary or fails to import different parts of the content. 

Workaround: Delete the glossary files:

string path = "File.docx";
using (Stream str = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
	using (ZipArchive archive = ZipArchive.Update(str, null))
	{
		foreach (ZipArchiveEntry entry in archive.Entries.ToList())
		{
			if (entry.FullName.Contains("glossary/"))
			{
				entry.Delete();
			}
		}
	}

	DocxFormatProvider provider = new DocxFormatProvider();
	RadFlowDocument flowDocument = provider.Import(str, null);
}

7 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 23 Jan 2026 15:11

Hello, Andre,

If it still doesn't work for your precise case, most probably it is not related to the glossary part inside the document which is the described issue in this public item. I would encourage you to submit a private support ticket from you Telerik account and provide the problematic document. Thus, we would be able to make an adequate analysis of the specific scenario and provide further assistance.

Thank you for your understanding and cooperation.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Andre
Posted on: 23 Jan 2026 14:23
Ok I was able to use the RadProcessing nuget package but it still didn't work for me.
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 22 Jan 2026 10:58

Hello, Andre,

Telerik Document Processing libraries offers RadZipLibrary. The suggested workaround uses its implementation for updating the zip archive and removing the duplicated glossary elements:

            string path = "your_document.docx";
            using (Stream str = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                using (Telerik.Windows.Zip.ZipArchive archive = Telerik.Windows.Zip.ZipArchive.Update(str, null))
                {
                    foreach (Telerik.Windows.Zip.ZipArchiveEntry entry in archive.Entries.ToList())
                    {
                        if (entry.FullName.Contains("glossary/"))
                        {
                            entry.Delete();
                        }
                    }
                }

                DocxFormatProvider provider = new DocxFormatProvider();
                RadFlowDocument flowDocument = provider.Import(str, null);
            }

 "System.IO.Compression" is a .NET namespace that provides classes for working with compressed data and archives, primarily ZIP files. It is very similar to the RadZipLibrary and it is up to the developer what code to use when it comes to manipulating the zip archive.

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Andre
Posted on: 21 Jan 2026 16:44

@Dess

This workaround isn't working for me. I get the same error. I did have to modify it a bit because I didn't know from which assembly the ZipArchive class was pulling from. I could only find the one from the "System.IO.Compression" assembly.

 

Here's my code:

// other using statements

using System.IO.Compression;

// other code

privatestaticDocxFormatProviderGetDocxFormatProvider(RecyclableMemoryStream inputStream)

    {
        using (ZipArchive archive = new(inputStream, ZipArchiveMode.Update, leaveOpen: true))
        {
            foreach (ZipArchiveEntry entry in archive.Entries.ToList())
            {
                if (entry.FullName.Contains("glossary/"))
                    entry.Delete();
            }
        }
        // reset position after modifying the zip
        inputStream.Position = 0;
        return new DocxFormatProvider();
    }
}
Andre
Posted on: 21 Jan 2026 14:10

Hi Dess,

I think I read the post too fast. I didn't realize that that was the workaround. I thought it's what the author had in place that wasn't working for them. I'll try it myself. Hopefully it works for my use case.

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 21 Jan 2026 12:24

Hello, Andre,

Currently, the most effective workaround is exactly what is provided in the item's description: deleting the glossary files (word/glossary/*) from the DOCX archive before importing the document. This prevents the duplicate key exception and avoids style overwrites or missing content that can occur due to conflicting definitions.

Have you tried this temporary solution? Are you facing any difficulties with this approach?

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Andre
Posted on: 20 Jan 2026 20:45
@guiguigui were you able to resolve this issue? Did you find a workaround?