Error importing docx file

2 posts, 0 answers
  1. Sean Cross
    Sean Cross avatar
    37 posts
    Member since:
    Oct 2009

    Posted 30 Jul 2012 Link to this post

    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?
  2. Vasil
    Admin
    Vasil avatar
    124 posts

    Posted 02 Aug 2012 Link to this post

    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.

  3. DevCraft banner
Back to Top