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

Exceptions with Docx files

1 Answer 84 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Daryl
Top achievements
Rank 1
Daryl asked on 30 Mar 2011, 09:07 AM
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.

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 31 Mar 2011, 05:41 PM
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
Tags
RichTextBox
Asked by
Daryl
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or