This is a migrated thread and some comments may be shown as answers.

Error importing docx file

1 Answer 149 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sean Cross
Top achievements
Rank 1
Sean Cross asked on 31 Jul 2012, 04:17 AM
I get the following error when tying to import some docx files containing images

System.Collections.Generic.KeyNotFoundException was unhandled by user code
  Message=The given key was not present in the dictionary.
  StackTrace:
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.PartRelationsImporter.GetRelationByID(String relationID)
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.InitIImageDocumentElementFromRelationID(IImageDocumentElement image, String imageRelationID)
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.ParagraphImporter.SetImageInlineProperties(String imageRelationID, IImageDocumentElement imageInline)
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.ParagraphImporter.ReadFloatingImageBlockFromDrawing()
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.ParagraphImporter.ReadImageFromDrawing()
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.ParagraphImporter.BuildInline(Style style)
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.ParagraphImporter.BuildRun(Style style, Paragraph paragraph)
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.ParagraphImporter.Import(Style parentStyle)
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.BuildDocumentFromBlocks(String endElementName)
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.HeaderFooterImporter.Import()
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadXmlContentFromPackage(DocxPartImporterBase importer)
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadXmlContentAndRelationsFromPackage(DocxPartImporterBase importer)
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadHeadersFooters()
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.Import()
       at Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider.Import(Stream input)
       at RtfEditor.MainPage.<>c__DisplayClass1.<ImportDocumentFromUrl>b__0(Object s, OpenReadCompletedEventArgs args)
       at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
       at System.Net.WebClient.OpenReadOperationCompleted(Object arg)
  InnerException:

The documents are generated server side based on Word templates.  They open correctly in Word.

You can download a sample file from http://pivotaltest.catalystrisk.co.nz/Downloads/AfterSpire.docx

Any ideas?

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 02 Aug 2012, 03:36 PM
Hello Sean,

Thank you for the sample document. It was not imported because it is missing the xml declaration in the file describing the relationships of the footer -"footer2.xml.rels". This file contains the relationship declaration for image3.jpeg which is positioned in the footer.

After adding the missing xml declaration, the file could be opened successfully. Please find attached a fixed version of your document. You could try to open it in our online demo.

Don't hesitate to contact us if you have other problems.

Greetings,
Vasil
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Sean Cross
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or