Exceptions with Docx files

2 posts, 0 answers
  1. Daryl
    Daryl avatar
    1 posts
    Member since:
    Sep 2007

    Posted 30 Mar 2011 Link to this post

    Hi, I've got the Q3.2010 RadControls and I've implemented an editor using the RichTextBox.

    What I need to be able to do is open a .docx file, and then use the RichTextBox's built in functionality to export to Html.

    This works perfectly with the reference document I was originally testing with.
    However, it turns out that the editor breaks with almost every other document I try.

    It seems to have something to do with images and/or certain formatting.

    The documents in question open just fine in the editor, and are displayed correctly.
    When I try to export to HTML it breaks.
    Below is the code I am using to export:
    HtmlFormatProvider provider = new HtmlFormatProvider();
    return provider.Export(document);


    This code throws out an error for most documents. The error varies slightly, but below is an example of the error:
    Uncaught Error: Unhandled Error in Silverlight Application Object reference not set to an instance of an object.   at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportImage_UriSource(ImageInline imageInline)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportImageInline(ImageInline imageInline)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportInline(Inline inline)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportParagraphContents(Paragraph paragraph)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportBlockContainer(IBlockContainer blockContainer)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportBodyContent()
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportBody()
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportDocumentInternal(RadDocument document, Stream output)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.Export(RadDocument document, Stream output)
       at Telerik.Windows.Documents.FormatProviders.Html.HtmlFormatProvider.Export(RadDocument document, Stream output)
       at Telerik.Windows.Documents.FormatProviders.Html.HtmlFormatProvider.Export(RadDocument document)
       at ArticleEditor.MainPage.ExportToString(RadDocument document)
       at ArticleEditor.MainPage.Save_Click(Object sender, RoutedEventArgs e)
       at System.Windows.Controls.Primitives.ButtonBase.OnClick()
       at System.Windows.Controls.Button.OnClick()
       at Telerik.Windows.Controls.RadButton.OnClick()
       at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
       at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)


    For another document I tried, I get the below error stack:
    Uncaught Error: Unhandled Error in Silverlight Application Object reference not set to an instance of an object.   at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportImage_UriSource(ImageInline imageInline)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportImageInline(ImageInline imageInline)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportInline(Inline inline)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportParagraphContents(Paragraph paragraph)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportBlockContainer(IBlockContainer blockContainer)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportTable(Table table)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportBlockContainer(IBlockContainer blockContainer)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportTable(Table table)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportBlockContainer(IBlockContainer blockContainer)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportTable(Table table)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportBlockContainer(IBlockContainer blockContainer)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportBodyContent()
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportBody()
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.ExportDocumentInternal(RadDocument document, Stream output)
       at Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlDocumentExporter.Export(RadDocument document, Stream output)
       at Telerik.Windows.Documents.FormatProviders.Html.HtmlFormatProvider.Export(RadDocument document, Stream output)
       at Telerik.Windows.Documents.FormatProviders.Html.HtmlFormatProvider.Export(RadDocument document)
       at ArticleEditor.MainPage.ExportToString(RadDocument document)
       at ArticleEditor.MainPage.Save_Click(Object sender, RoutedEventArgs e)
       at System.Windows.Controls.Primitives.ButtonBase.OnClick()
       at System.Windows.Controls.Button.OnClick()
       at Telerik.Windows.Controls.RadButton.OnClick()
       at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
       at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)


    Please advise as to what I could try to get this working? I need to deliver this solution ASAP.

    Thanks.
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 31 Mar 2011 Link to this post

    Hi Daryl,

    This problem occurs when the ImageExportMode of the HtmlFormatProvider is set to UriSource and an image doesn't have a URI. As this action is invalid, an exception is thrown. However, in the next minor release (Q1 SP1) we will make sure that even in these cases, the document exports correctly, even if some images are missing.

    Best wishes,
    Iva
    the Telerik team
Back to Top