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!