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

Problem with Exporting RadDocument in HTML using HtmlFormatProvider

3 Answers 181 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
alino
Top achievements
Rank 1
alino asked on 13 May 2011, 04:47 PM
Hi,

I have a problem of exporting a RadDocument which has inlineImage. I Created a RadDocument which I use to export in differnt format using different providers. In My RadDocument I have inlineImage i inserted using a MemoryStream containing a PNG Image. When I export in HTML i have only the empty box but without image... Is there any particular settings to make Exporting image correctly in the Html document ??

Thanks for your precious help.


Alino

3 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 18 May 2011, 05:31 PM
Hi alino,

There are HtmlExportSettings that can be used in order to customize the way that images are exported - e.g. inline (encoded) or through their UriSource.
The default value is Base64Encoded, which for some reason does not work well for images, which are encoded to strings of length larger than 32 KB. (Some browsers do not render the pages, if the size of the image raw data is that big.) Therefore, we have included one other image export mode - Base64EncodedSplit, which you can try if the size of the image is the cause of the misbehavior.
If that does not help, we would appreciate some more details on your implementation. An outline of the image can also occur when the source of the image is not found or the stream does not contain proper image data.
I hope that helps.

All the best,
Iva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chandan
Top achievements
Rank 1
answered on 21 Jan 2014, 10:27 AM

Hi Iva,

I am trying to export content of Rad rich text box using HTML provider.

I have inserted image in Rad rich text box of size 36 KB.

Code snippet:

HtmlExportSettings exportSettings = new HtmlExportSettings();

            HtmlFormatProvider provider = DocumentFormatProvidersManager.GetProviderByExtension("html") as HtmlFormatProvider;

            exportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;

            exportSettings.StylesExportMode = StylesExportMode.Inline;

            exportSettings.ImageExportMode = ImageExportMode.Base64EncodedSplit;

            HtmlDataProvider htmldataprovider = new HtmlDataProvider();

            htmldataprovider.FormatProvider = provider;

            provider.ExportSettings = exportSettings;
         string result = provider.Export(editor.Document);

when I am trying to send the result as body of email. Image is not getting displayed in outlook.  it is very urgent requirement of my client.

Thanks

Chandan



  
0
Missing User
answered on 24 Jan 2014, 09:02 AM
Hi Chandan,

Indeed, you experienced a security restriction regarding MS Outlook. Most email clients do not show embedded images and this is how RadRichTextBox exports content to HTML. If you try opening the same file in a browser you could verify that it is shown properly.

However, I would recommend you to handle the export of your image separately. This would avoid any blocking display. If you are going to accomplish this, you have to set the ImageExportMode property of the HtmlExportSettings class to ImageExportingEvent and to subscribe for the ImageExportingEvent. I've attached a small running example to illustrate to you how this could be achieved.

I hope this helps!

Regards,
Yancho
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
RichTextBox
Asked by
alino
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Chandan
Top achievements
Rank 1
Missing User
Share this question
or