Docx Import returns Error: System.ArgumentException: 'An item with the same key has already been added. Key: 0'

1 Answer 116 Views
PdfProcessing WordsProcessing
Christopher
Top achievements
Rank 1
Christopher asked on 18 Oct 2022, 07:58 AM

Hello,

we are currently in need for a docx to pdf converter.

The docx file contains placeholders created in word. When we want to read it in with the Telerik documents package it gives us an error. 

The Import() function returns:

Error: System.ArgumentException: 'An item with the same key has already been added. Key: 0'

Here is the code we are using:

        static void ConverDocxToPdf(string path, string resultPath)
        {
            var docxPRovider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
            var pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();

            byte[] docBytes = File.ReadAllBytes(path);
            var document = docxPRovider.Import(docBytes);

            var resultBytes = pdfProvider.Export(document);
            File.WriteAllBytes(resultPath, resultBytes);
        }

 

I attached one of the templates we are using. When you try to read it in, it will return the mentioned error.

 

Thank you in advance!

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 19 Oct 2022, 07:58 AM

Hello Christopher,

This is a known issue that is already logged on our feedback portal. You can track its progress, subscribe to status changes, and add your comment to it here: WordsProcessing: Cannot properly import a document that has duplicating xml definitions in the original and glossary documents

I am afraid I cannot suggest a workaround for this.

I want to apologize for the inconvenience this issue is causing you.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
PdfProcessing WordsProcessing
Asked by
Christopher
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or